/* AlgoPaca Shared Desk Compiled & Compressed Stylesheet Bundle (Compressed) */
/**
 * AlgoPaca Shared Desk Compiled & Compressed Stylesheet Bundle
 * Automatically compiled and optimized from modular source files.
 */


/* ── Module: common/tokens-and-resets.css ─────────────────────────────────────── */

/**
 * Common Design Tokens, Palettes, Resets, and NiceSelect
 * AlgoPaca Modular Stylesheet
 */

:root,
[data-theme="obsidian"] {
  --ink: #0c1219;
  --slate: #141c27;
  --panel: #1a2433;
  --panel-bg: #101622;
  --input-bg: #0d1322;
  /* Terminal/console surfaces stay dark in every theme — a log readout is the
     one place where the desk keeps its terminal character. */
  --console-bg: #070b12;
  --console-line: #1e293b;
  /* Fourth semantic hue, used for the Owner role and the trading-engine metric
     so neither borrows the buy/sell/warn meanings. */
  --violet: #c084fc;
  --violet-deep: #7c3aed;
  --cyan: #38bdf8;
  --line: #2a384c;
  --line-soft: rgba(255, 255, 255, 0.06);
  --surface-soft: rgba(255, 255, 255, 0.025);
  --surface: var(--surface-soft);
  --text: #f2ebe1;
  --muted: #8f949b;
  --copper: #d4894c;
  --copper-deep: #b56a32;
  --copper-text: #0c1219;
  --buy: #3fbf8f;
  --sell: #e35d5d;
  --hold: #8b9aab;
  --glow: rgba(212, 137, 76, 0.18);
  --danger-bg: #5a2626;
  --ok: #3fbf8f;
  --warn: #f0c674;
  --error: #ff9999;
  --error-soft: #ffd7d7;
  --accent: var(--buy);
  --danger: var(--sell);
  --text-muted: var(--muted);
  --radius-sm: 0.5rem;
  --radius-md: 0.85rem;
  --radius-lg: 1.15rem;
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 10px 25px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.7);
  --display: "Fraunces", Georgia, serif;
  --ui: "Schibsted Grotesk", "Avenir Next", sans-serif;
  --mono: "IBM Plex Mono", "SF Mono", Monaco, Menlo, Consolas, "Roboto Mono", "Ubuntu Mono", monospace;
  --mobile-nav-height: 62px;
  --mobile-header-height: 52px;
  color-scheme: dark;
}

[data-theme="midnight"] {
  --ink: #070d18;
  --slate: #0d1728;
  --panel: #132238;
  --panel-bg: #0c1728;
  --input-bg: #0a1424;
  --console-bg: #050b14;
  --console-line: #1e3556;
  --violet: #a78bfa;
  --violet-deep: #7c3aed;
  --cyan: #22d3ee;
  --line: #1e3556;
  --line-soft: rgba(56, 189, 248, 0.08);
  --surface-soft: rgba(56, 189, 248, 0.03);
  --text: #f1f5f9;
  --muted: #8ba2c4;
  --copper: #38bdf8;
  --copper-deep: #0284c7;
  --copper-text: #070d18;
  --buy: #34d399;
  --sell: #f87171;
  --hold: #7dd3fc;
  --glow: rgba(56, 189, 248, 0.22);
  --danger-bg: #451a1a;
  --ok: #34d399;
  --warn: #facc15;
  --error: #fca5a5;
  --error-soft: #fee2e2;
  --shadow-sm: 0 4px 12px rgba(2, 6, 23, 0.45);
  --shadow-md: 0 10px 25px rgba(2, 6, 23, 0.6);
  --shadow-lg: 0 20px 40px rgba(2, 6, 23, 0.8);
  color-scheme: dark;
}

[data-theme="emerald"] {
  --ink: #07130e;
  --slate: #0d1f18;
  --panel: #132d23;
  --panel-bg: #0c1f17;
  --input-bg: #091a13;
  --console-bg: #04100b;
  --console-line: #1c4536;
  --violet: #c084fc;
  --violet-deep: #7c3aed;
  --cyan: #38bdf8;
  --line: #1c4536;
  --line-soft: rgba(63, 191, 143, 0.09);
  --surface-soft: rgba(63, 191, 143, 0.035);
  --text: #ecfdf5;
  --muted: #82a798;
  --copper: #3fbf8f;
  --copper-deep: #22996d;
  --copper-text: #05160e;
  --buy: #10b981;
  --sell: #f43f5e;
  --hold: #6ee7b7;
  --glow: rgba(63, 191, 143, 0.22);
  --danger-bg: #4c111d;
  --ok: #10b981;
  --warn: #f59e0b;
  --error: #fda4af;
  --error-soft: #ffe4e6;
  --shadow-sm: 0 4px 12px rgba(3, 18, 12, 0.5);
  --shadow-md: 0 10px 25px rgba(3, 18, 12, 0.65);
  --shadow-lg: 0 20px 40px rgba(3, 18, 12, 0.8);
  color-scheme: dark;
}

[data-theme="daylight"] {
  --ink: #f8fafc;
  --slate: #f1f5f9;
  --panel: #ffffff;
  --panel-bg: #ffffff;
  --input-bg: #ffffff;
  --console-bg: #0f172a;
  --console-line: #334155;
  --line: #cbd5e1;
  --line-soft: rgba(15, 23, 42, 0.08);
  --surface-soft: rgba(15, 23, 42, 0.04);
  --text: #0f172a;
  --muted: #64748b;
  --copper: #2563eb;
  --copper-deep: #1d4ed8;
  --copper-text: #ffffff;
  --warn: #b45309;
  --error: #dc2626;
  --error-soft: #fee2e2;
  --buy: #059669;
  --sell: #dc2626;
  --hold: #64748b;
  --violet: #7c3aed;
  --violet-deep: #5b21b6;
  --cyan: #0284c7;
  --glow: rgba(37, 99, 235, 0.16);
  --danger-bg: #fee2e2;
  --ok: #059669;
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.09);
  --shadow-lg: 0 16px 36px rgba(15, 23, 42, 0.12);
  --accent: var(--buy);
  --danger: var(--sell);
  --text-muted: var(--muted);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--ink);
  color: var(--text);
  font-family: var(--ui);
}

body {
  position: relative;
  overflow-x: visible;
  padding-bottom: env(safe-area-inset-bottom);
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  z-index: 20;
  padding: 0.55rem 0.85rem;
  background: var(--text);
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  border-radius: var(--radius-sm);
}

.skip-link:focus {
  top: 1rem;
}

#main,
#signal-wall,
#history-panel {
  scroll-margin-top: 1rem;
}

/* Ambient Background Glow & Depth Grid */
.atmosphere {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 80% 50% at 15% 10%, color-mix(in srgb, var(--copper) 22%, transparent), transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 80%, color-mix(in srgb, var(--buy) 16%, transparent), transparent 50%),
    radial-gradient(ellipse 50% 50% at 50% 100%, color-mix(in srgb, var(--panel) 80%, transparent), transparent 60%),
    linear-gradient(180deg, color-mix(in srgb, var(--slate) 60%, var(--ink)) 0%, var(--ink) 45%, var(--ink) 100%);
}

[data-theme="daylight"] .atmosphere {
  background:
    radial-gradient(ellipse 80% 50% at 15% 10%, rgba(37, 99, 235, 0.06), transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 80%, rgba(5, 150, 105, 0.04), transparent 50%),
    linear-gradient(180deg, #ffffff 0%, #f8fafc 45%, #f1f5f9 100%);
}

[data-theme="daylight"] .atmosphere::before {
  opacity: 0.22;
}

.atmosphere::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle 500px at 15% -5%, color-mix(in srgb, var(--copper) 16%, transparent), transparent 70%),
    radial-gradient(circle 480px at 95% 20%, color-mix(in srgb, var(--buy) 14%, transparent), transparent 70%),
    radial-gradient(circle 550px at -5% 60%, color-mix(in srgb, var(--copper) 10%, transparent), transparent 70%);
}

.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.04;
  background-size: 40px 40px;
  background-image:
    linear-gradient(to right, #ffffff 1px, transparent 1px),
    linear-gradient(to bottom, #ffffff 1px, transparent 1px);
}

[data-theme="daylight"] .atmosphere::after {
  opacity: 0.045;
  background-image:
    linear-gradient(to right, #0f172a 1px, transparent 1px),
    linear-gradient(to bottom, #0f172a 1px, transparent 1px);
}

.app {
  position: relative;
  z-index: 1;
  max-width: 1560px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
  padding-left: max(1.25rem, env(safe-area-inset-left));
  padding-right: max(1.25rem, env(safe-area-inset-right));
}

.masthead {
  display: grid;
  gap: 1rem;
  margin-bottom: 1.75rem;
  padding-bottom: 1.4rem;
  /* A hairline that fades out to the right, so the header reads as its own
     band without drawing a hard box across the page. */
  border-bottom: 1px solid transparent;
  border-image: linear-gradient(90deg, var(--line) 0%, rgba(42, 56, 76, 0.35) 55%, transparent 100%) 1;
  animation: rise 0.7s ease both;
  position: relative;
  z-index: 100;
}

.masthead-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.25rem 2rem;
  /* Grid items default to `min-width: auto`, which lets this row size to the
     nav's max-content and spill out of the masthead's column. */
  min-width: 0;
  position: relative;
  z-index: 100;
}

.masthead-brand {
  display: grid;
  gap: 0.5rem;
  /* Allowed to shrink so the tagline wraps instead of shouldering the nav
     onto its own row — its unwrapped max-content width is wider than the
     34rem it actually renders at. */
  flex: 1 1 20rem;
  min-width: 0;
}

.masthead-brand-header {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.masthead-logo-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  flex-shrink: 0;
  border-radius: calc(var(--radius-md) + 2px);
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), filter 0.22s ease;
}

.masthead-logo-link:hover {
  transform: translateY(-2px) scale(1.04);
  filter: drop-shadow(0 6px 16px rgba(245, 158, 11, 0.32));
}

.masthead-logo-link:active {
  transform: translateY(0) scale(0.98);
}

.masthead-logo-img {
  width: 48px;
  height: 48px;
  border-radius: inherit;
  display: block;
}

.masthead-brand-text {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

/* Note: Desktop navigation styles have been modularized into /static/css/desk-shell.css for device-specific loading */

.lang-select:focus-visible {
  outline: 2px solid var(--copper);
  outline-offset: 2px;
}

/* ==========================================================================
   Masthead Stock Ticker Search
   ========================================================================== */

.masthead-search {
  position: relative;
  flex: 0 1 340px;
  max-width: 420px;
  z-index: 105;
  padding-top: 0.15rem;
}

@media (min-width: 769px) {
  .masthead-search {
    min-width: 220px;
  }
}

.masthead-search-form {
  position: relative;
  width: 100%;
  margin: 0;
  padding: 0;
}

.masthead-search-box {
  display: flex;
  align-items: center;
  position: relative;
  background: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 0.35rem 0.65rem 0.35rem 0.75rem;
  gap: 0.5rem;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  min-height: 38px;
}

.masthead-search-box:hover {
  border-color: color-mix(in srgb, var(--copper) 45%, var(--line));
}

.masthead-search-box.has-focus,
.masthead-search-box:focus-within {
  border-color: var(--copper);
  box-shadow: 0 0 0 3px var(--glow), inset 0 1px 2px rgba(0, 0, 0, 0.4);
  background: var(--panel-bg);
}

.masthead-search-icon {
  flex-shrink: 0;
  color: var(--muted);
  width: 16px;
  height: 16px;
  transition: color 0.2s ease;
}

.masthead-search-box:focus-within .masthead-search-icon {
  color: var(--copper);
}

.masthead-search-input {
  flex: 1 1 auto;
  min-width: 0;
  background: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  font-family: var(--ui);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
}

.masthead-search-input::placeholder {
  color: var(--muted);
  opacity: 0.75;
  font-size: 0.82rem;
}

.masthead-search-input::-webkit-search-decoration,
.masthead-search-input::-webkit-search-cancel-button,
.masthead-search-input::-webkit-search-results-button,
.masthead-search-input::-webkit-search-results-decoration {
  display: none;
  -webkit-appearance: none;
}

.masthead-search-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

button.masthead-search-clear,
.masthead-search-clear {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 20px !important;
  height: 20px !important;
  min-width: 20px !important;
  min-height: 20px !important;
  max-width: 20px !important;
  max-height: 20px !important;
  padding: 0 !important;
  margin: 0 !important;
  border-radius: 50% !important;
  border: none !important;
  background: color-mix(in srgb, var(--text) 8%, transparent) !important;
  color: var(--muted) !important;
  cursor: pointer !important;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease !important;
  flex-shrink: 0 !important;
  box-sizing: border-box !important;
  line-height: 1 !important;
  aspect-ratio: 1 / 1 !important;
}

button.masthead-search-clear:hover,
.masthead-search-clear:hover {
  background: color-mix(in srgb, var(--text) 18%, transparent) !important;
  color: var(--text) !important;
}

button.masthead-search-clear:active,
.masthead-search-clear:active {
  transform: scale(0.92) !important;
}

button.masthead-search-clear svg,
.masthead-search-clear svg {
  display: block;
  width: 10px;
  height: 10px;
  flex-shrink: 0;
  pointer-events: none;
}

.masthead-search-kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--muted);
  background: color-mix(in srgb, var(--text) 5%, transparent);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.12rem 0.35rem;
  line-height: 1;
  letter-spacing: 0.02em;
  user-select: none;
  pointer-events: none;
  box-shadow: 0 1px 0 var(--line-soft);
}

.masthead-search-cancel {
  display: none;
}

/* Search Dropdown */
.masthead-search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  min-width: 340px;
  max-width: 440px;
  max-height: 420px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--panel);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow:
    inset 0 1px 0 var(--line-soft),
    var(--shadow-lg);
  padding: 0.4rem;
  z-index: 1000;
  animation: searchFadeIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes searchFadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.masthead-search-dropdown[hidden] {
  display: none !important;
}

.search-section-label {
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 0.35rem 0.6rem 0.2rem;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.search-results-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.search-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.6rem;
  border-radius: calc(var(--radius-sm) - 1px);
  text-decoration: none;
  color: var(--text);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
  user-select: none;
  gap: 0.5rem;
}

.search-result-item:hover,
.search-result-item.is-selected {
  background: color-mix(in srgb, var(--copper) 12%, transparent);
  border-color: color-mix(in srgb, var(--copper) 30%, transparent);
}

.search-item-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1 1 auto;
}

.search-item-top {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.search-item-symbol {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.88rem;
  letter-spacing: 0.04em;
  color: var(--text);
}

.search-item-name {
  font-size: 0.76rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.search-item-actions {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}

.search-action-btn {
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--text) 5%, transparent);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.2;
  text-decoration: none;
}

.search-action-btn:hover {
  background: var(--copper);
  color: var(--copper-text);
  border-color: var(--copper);
}

.search-action-btn.is-trade {
  background: rgba(63, 191, 143, 0.12);
  color: var(--buy);
  border-color: rgba(63, 191, 143, 0.28);
}

.search-action-btn.is-trade:hover {
  background: var(--buy);
  color: #0c1219;
  border-color: var(--buy);
}

.search-dropdown-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0.6rem 0.15rem;
  margin-top: 0.3rem;
  border-top: 1px solid var(--line-soft);
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.search-empty-msg {
  padding: 1.2rem 0.8rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
}

.masthead-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: 0 1 auto;
  flex-wrap: wrap;
  /* Keeps the bar optically level with the eyebrow rather than the cap
     height of the display serif below it. */
  padding-top: 0.15rem;
  position: relative;
  z-index: 100;
}

.lang-switcher {
  position: relative;
  z-index: 100;
  display: inline-flex;
  align-items: center;
}

.lang-switcher::before {
  content: "";
  position: absolute;
  left: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  width: 0.8rem;
  height: 0.8rem;
  pointer-events: none;
  z-index: 3;
  /* Line-art globe, so the control reads as UI chrome instead of an emoji
     that each platform renders in its own colour. */
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239aa8b8' stroke-width='1.7' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M3 12h18M12 3a15 15 0 0 1 0 18a15 15 0 0 1 0-18'/%3E%3C/svg%3E") no-repeat center / contain;
  transition: opacity 0.2s ease;
  opacity: 0.85;
}

.lang-switcher:hover::before {
  opacity: 1;
}

/* Fallback native select if NiceSelect is not active */
select.lang-select {
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.03em;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  /* A secondary control, so it sits smaller than the nav rail rather than
     matching its height — it is set once and rarely touched again. */
  padding: 0.42rem 1.35rem 0.42rem 1.65rem;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  box-shadow: inset 0 1px 0 var(--line-soft);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  background-color: var(--panel);
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  transition: border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

select.lang-select:hover,
select.lang-select:focus {
  color: var(--text);
  border-color: var(--copper);
  box-shadow:
    inset 0 1px 0 var(--line-soft),
    0 0 0 2px var(--glow);
}

select.lang-select option {
  background: var(--panel);
  color: var(--text);
  padding: 0.4rem;
}

/* Hide native select completely once NiceSelect is bound so it doesn't take flex space */
.lang-switcher select.hidden-select,
select.lang-select.hidden-select {
  display: none !important;
  position: absolute !important;
  width: 0 !important;
  height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
}

/* ── NiceSelect Language Switcher Customization ────────────── */
.lang-switcher .nice-select {
  float: none;
  clear: none;
  display: inline-flex;
  align-items: center;
  width: auto;
  min-width: 0;
  height: 2.15rem;
  line-height: 2.15rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding-left: 1.75rem;
  padding-right: 1.4rem;
  background-color: color-mix(in srgb, var(--panel) 85%, transparent);
  background-image: none !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: inset 0 1px 0 var(--line-soft);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.lang-switcher .nice-select:hover,
.lang-switcher .nice-select:focus,
.lang-switcher .nice-select.open {
  color: var(--text);
  border-color: var(--copper);
  background-color: var(--slate);
  box-shadow:
    inset 0 1px 0 var(--line-soft),
    0 0 0 2px var(--glow);
}

.lang-switcher .nice-select:after {
  border-bottom: 2px solid var(--muted);
  border-right: 2px solid var(--muted);
  right: 0.55rem;
  width: 5px;
  height: 5px;
  margin-top: 1px;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.lang-switcher .nice-select:hover:after,
.lang-switcher .nice-select:focus:after,
.lang-switcher .nice-select.open:after {
  border-bottom-color: var(--copper);
  border-right-color: var(--copper);
}

.lang-switcher .nice-select .current {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: normal;
}

.lang-switcher .nice-select .nice-select-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 100%;
  width: max-content;
  max-height: min(16rem, 50vh);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background-color: var(--panel);
  box-shadow: var(--shadow-md);
  z-index: 200;
  margin-top: 0;
}

/* Desk footer language dropdown opens upwards */
.desk-footer .lang-switcher .nice-select .nice-select-dropdown {
  bottom: calc(100% + 4px);
  top: auto;
  transform-origin: bottom center;
}

.lang-switcher .nice-select .list {
  padding: 0.25rem 0;
  margin: 0;
  list-style: none;
}

.lang-switcher .nice-select .option {
  min-height: 1.95rem;
  line-height: 1.95rem;
  padding: 0 0.85rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.lang-switcher .nice-select .option:hover,
.lang-switcher .nice-select .option.focus,
.lang-switcher .nice-select .option.selected.focus {
  background-color: color-mix(in srgb, var(--copper) 16%, transparent);
  color: var(--text);
}

.lang-switcher .nice-select .option.selected {
  font-weight: 600;
  color: var(--copper);
  background-color: color-mix(in srgb, var(--copper) 8%, transparent);
}



/* ── Module: common/sidebar.css ─────────────────────────────────────── */

/**
 * AlgoPaca - Reddit-style Sidebar and Modern Top Header Styles
 * Universal modern layout with collapsible left sidebar and full-width top navigation.
 */

:root {
  --sidebar-width: 250px;
  --header-height: 56px;
}

/* ── App Shell Reset for Edge-to-Edge Navigation ────────────── */
.app {
  max-width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  position: relative;
  z-index: 1;
}

.app-header .masthead-search-dropdown {
  max-width: 100% !important;
}

/* ── Top Header Bar ─────────────────────────────────────────── */
.app-header.masthead {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  z-index: 1050;
  margin: 0 !important;
  padding: 0 1.25rem !important;
  background: color-mix(in srgb, var(--panel) 94%, var(--bg));
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  display: block !important;
  box-sizing: border-box;
}

.app-header .masthead-top {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  height: 100% !important;
  gap: 1.25rem !important;
  flex-wrap: nowrap !important;
  min-width: 0;
}

/* Header Left: Toggle & Brand */
.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.header-sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--text);
  cursor: pointer;
  padding: 0;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.header-sidebar-toggle:hover {
  background: color-mix(in srgb, var(--copper) 14%, var(--surface-soft));
  border-color: var(--copper);
  color: var(--copper);
  transform: scale(1.04);
}

.header-sidebar-toggle:active {
  transform: scale(0.96);
}

.app-header .masthead-logo-link {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: opacity 0.18s ease;
}

.app-header .masthead-logo-link:hover {
  opacity: 0.92;
}

.app-header .masthead-logo-img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: block;
}

.masthead-brand-name {
  font-family: var(--mono);
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

/* Header Center: Pill Search Bar (Reddit-style) */
.app-header .masthead-search {
  flex: 1 1 540px;
  max-width: 600px;
  min-width: 180px;
  padding: 0;
}

.app-header .masthead-search-box {
  border-radius: 9999px !important;
  background: var(--surface-soft) !important;
  border: 1px solid var(--line-soft) !important;
  min-height: 40px !important;
  padding: 0.35rem 0.95rem !important;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.app-header .masthead-search-box:hover {
  border-color: color-mix(in srgb, var(--copper) 45%, var(--line)) !important;
  background: color-mix(in srgb, var(--surface-soft) 80%, var(--panel)) !important;
}

.app-header .masthead-search-box.has-focus,
.app-header .masthead-search-box:focus-within {
  border-color: var(--copper) !important;
  box-shadow: 0 0 0 3px var(--glow) !important;
  background: var(--panel) !important;
}

/* Header Right: Actions, Notifications, Profile */
.app-header .masthead-right {
  display: flex !important;
  align-items: center !important;
  gap: 0.65rem !important;
  flex-shrink: 0 !important;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.header-create-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.38rem 0.85rem;
  border-radius: 9999px;
  background: color-mix(in srgb, var(--copper) 14%, var(--surface-soft));
  border: 1px solid color-mix(in srgb, var(--copper) 35%, transparent);
  color: var(--copper);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.header-create-btn:hover {
  background: color-mix(in srgb, var(--copper) 22%, var(--surface-soft));
  border-color: var(--copper);
  color: var(--copper);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--copper) 25%, transparent);
}

.header-create-btn:active {
  transform: translateY(0);
}

.header-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  position: relative;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.header-icon-btn:hover {
  border-color: var(--copper);
  color: var(--text);
  background: var(--panel);
}

.header-badge-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--copper);
  box-shadow: 0 0 6px var(--copper);
}

.header-badge-dot[hidden] {
  display: none !important;
}

/* ── Modern Notifications Popover ─────────────────────────── */
.header-notif-widget {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.header-notif-popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 325px;
  max-width: calc(100vw - 1.25rem);
  background: var(--panel) !important;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.78), 0 0 0 1px var(--line);
  display: flex;
  flex-direction: column;
  z-index: 1200;
  overflow: hidden;
  animation: notifFadeIn 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

.header-notif-popover *,
.header-notif-popover *::before,
.header-notif-popover *::after {
  box-sizing: border-box;
}

.header-notif-popover[hidden] {
  display: none !important;
}

@keyframes notifFadeIn {
  from {
    opacity: 0;
    transform: translateY(-5px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.notif-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.48rem 0.75rem;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 85%, var(--bg));
}

.notif-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.notif-popover-title {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.notif-count-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.08rem 0.38rem;
  border-radius: 9999px;
  background: color-mix(in srgb, var(--copper) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--copper) 35%, transparent);
  color: var(--copper);
  font-size: 0.6rem;
  font-family: var(--mono);
  font-weight: 600;
  line-height: 1;
}

.notif-action-btn {
  background: none;
  border: none;
  font-size: 0.66rem;
  color: var(--muted);
  cursor: pointer;
  padding: 0.15rem 0.35rem;
  border-radius: var(--radius-xs);
  transition: color 0.15s ease, background 0.15s ease;
}

.notif-action-btn:hover {
  color: var(--copper);
  background: var(--surface-soft);
}

.notif-filters-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 0.75rem;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 92%, var(--bg));
  overflow-x: auto;
  scrollbar-width: none;
}

.notif-filters-bar::-webkit-scrollbar {
  display: none;
}

.notif-filter-tab {
  position: relative;
  padding: 0.38rem 0.15rem 0.38rem;
  font-size: 0.64rem;
  font-family: var(--mono);
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--muted);
  background: transparent;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1.2;
}

.notif-filter-tab:hover:not(.is-active) {
  color: var(--text);
}

.notif-filter-tab::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: transparent;
  border-radius: 9999px;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.notif-filter-tab.is-active {
  color: var(--copper);
  font-weight: 700;
}

.notif-filter-tab.is-active::after {
  background: var(--copper);
  box-shadow: 0 0 8px color-mix(in srgb, var(--copper) 60%, transparent);
}

.notif-popover-body {
  max-height: 280px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--panel);
}

.notif-list {
  display: flex;
  flex-direction: column;
}

.notif-item {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.48rem 0.75rem;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  cursor: pointer;
  transition: background 0.15s ease;
  text-decoration: none;
  background: var(--panel);
}

.notif-item:last-child {
  border-bottom: none;
}

.notif-item:hover {
  background: color-mix(in srgb, var(--panel) 82%, var(--surface-soft));
}

.notif-item.is-unread {
  background: color-mix(in srgb, var(--panel) 88%, var(--copper));
}

.notif-icon-box {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.notif-icon-box.is-trades {
  background: color-mix(in srgb, var(--buy) 16%, transparent);
  color: var(--buy);
}

.notif-icon-box.is-risk {
  background: color-mix(in srgb, #f59e0b 16%, transparent);
  color: #f59e0b;
}

.notif-icon-box.is-system {
  background: color-mix(in srgb, var(--copper) 16%, transparent);
  color: var(--copper);
}

.notif-content {
  flex: 1;
  min-width: 0;
}

.notif-heading-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.4rem;
  margin-bottom: 0.12rem;
}

.notif-item-title {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notif-item-time {
  font-size: 0.58rem;
  font-family: var(--mono);
  color: var(--muted);
  flex-shrink: 0;
}

.notif-item-desc {
  font-size: 0.66rem;
  color: var(--muted);
  line-height: 1.25;
  margin: 0 0 0.22rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.notif-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.notif-badge-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.05rem 0.28rem;
  border-radius: 3px;
  font-size: 0.54rem;
  font-family: var(--mono);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.notif-badge-pill.is-trades {
  background: color-mix(in srgb, var(--buy) 14%, transparent);
  color: var(--buy);
}

.notif-badge-pill.is-risk {
  background: color-mix(in srgb, #f59e0b 14%, transparent);
  color: #f59e0b;
}

.notif-badge-pill.is-system {
  background: color-mix(in srgb, var(--line) 80%, transparent);
  color: var(--muted);
}

.notif-item-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.notif-unread-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--copper);
  box-shadow: 0 0 5px var(--copper);
  flex-shrink: 0;
}

.notif-dismiss-btn {
  opacity: 0;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0.1rem 0.25rem;
  border-radius: 3px;
  font-size: 0.72rem;
  line-height: 1;
  transition: opacity 0.15s ease, color 0.15s ease;
}

.notif-item:hover .notif-dismiss-btn {
  opacity: 0.7;
}

.notif-dismiss-btn:hover {
  opacity: 1;
  color: var(--sell);
}

.notif-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
  text-align: center;
}

.notif-empty-icon {
  color: var(--copper);
  margin-bottom: 0.45rem;
  opacity: 0.85;
}

.notif-empty-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.2rem;
}

.notif-empty-sub {
  font-size: 0.67rem;
  color: var(--muted);
  line-height: 1.35;
  max-width: 220px;
}

.notif-popover-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.42rem 0.75rem;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 90%, var(--bg));
}

.notif-footer-link {
  font-size: 0.66rem;
  color: var(--copper);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.15s ease;
}

.notif-footer-link:hover {
  text-decoration: underline;
}

.notif-clear-all-btn {
  background: none;
  border: none;
  font-size: 0.66rem;
  color: var(--muted);
  cursor: pointer;
  padding: 0.15rem 0.3rem;
  transition: color 0.15s ease;
}

.notif-clear-all-btn:hover {
  color: var(--sell);
}

/* Reddit-style User Avatar Presence Indicator */
.masthead-user-widget {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.masthead-user-widget::after {
  content: "";
  position: absolute;
  bottom: 0px;
  right: 0px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #10b981;
  border: 2px solid var(--panel);
  pointer-events: none;
  box-shadow: 0 0 4px rgba(16, 185, 129, 0.6);
  z-index: 2;
}

/* ── Left Sidebar (Reddit-style) ────────────────────────────── */
.app-sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  z-index: 850;
  background: color-mix(in srgb, var(--panel) 96%, var(--bg));
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.22s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

.sidebar-scroll-wrap {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.75rem 0.65rem 1.25rem;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.sidebar-scroll-wrap::-webkit-scrollbar {
  width: 5px;
}

.sidebar-scroll-wrap::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-scroll-wrap::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 4px;
}

.sidebar-nav-group {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
}

/* Nav Item (Reddit pill style) */
.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.52rem 0.85rem;
  border-radius: 9999px;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 500;
  min-height: 38px;
  box-sizing: border-box;
  transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
  position: relative;
}

.sidebar-nav-item:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.sidebar-nav-item.is-active {
  background: color-mix(in srgb, var(--copper) 14%, var(--surface-soft));
  color: var(--copper);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--copper) 30%, transparent);
}

.sidebar-nav-item.is-action {
  color: var(--copper);
}

.sidebar-nav-item.is-action:hover {
  background: color-mix(in srgb, var(--copper) 12%, var(--surface-soft));
}

.sidebar-nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: inherit;
}

.sidebar-nav-icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
}

.sidebar-nav-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
}

/* Nav Item with Subtext (Reddit-style two-line item) */
.sidebar-nav-item.with-subtext {
  min-height: 44px;
  padding: 0.42rem 0.85rem;
}

.sidebar-nav-item.with-subtext.is-active {
  background: color-mix(in srgb, var(--copper) 16%, var(--surface-soft)) !important;
  border: 1px solid color-mix(in srgb, var(--copper) 35%, transparent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  border-radius: var(--radius-md, 12px) !important;
}

.sidebar-nav-item.with-subtext.is-active .sidebar-nav-label {
  color: var(--copper);
  font-weight: 700;
}

.sidebar-nav-item.with-subtext.is-active .sidebar-nav-subtext {
  color: var(--text);
  opacity: 0.9;
}

.sidebar-nav-text-group {
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
  min-width: 0;
  flex: 1 1 auto;
}

.sidebar-nav-subtext {
  font-size: 0.67rem;
  color: var(--muted);
  opacity: 0.75;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.1;
}

body.sidebar-collapsed .sidebar-nav-subtext,
body.sidebar-collapsed .sidebar-nav-text-group {
  display: none !important;
}

/* Bot Colored Indicator Dots */
.sidebar-bot-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-left: 4px;
  margin-right: 5px;
}

.sidebar-bot-dot.is-cyan {
  background: #06b6d4;
  box-shadow: 0 0 6px rgba(6, 182, 212, 0.45);
}

.sidebar-bot-dot.is-amber {
  background: #f59e0b;
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.45);
}

.sidebar-bot-dot.is-gold {
  background: #eab308;
  box-shadow: 0 0 6px rgba(234, 179, 8, 0.45);
}

.sidebar-divider {
  height: 1px;
  background: var(--line-soft);
  margin: 0.65rem 0.5rem;
}

/* Collapsible Section Headers (Reddit-style) */
.sidebar-section {
  margin-bottom: 0.35rem;
}

.sidebar-section-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.85rem 0.35rem;
  background: transparent;
  border: none;
  font-family: var(--mono);
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  border-radius: var(--radius-sm);
  transition: color 0.16s ease;
}

.sidebar-section-header:hover {
  color: var(--text);
}

.sidebar-section-chevron {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  flex-shrink: 0;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-section-content {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.sidebar-section:not(.is-open) .sidebar-section-content {
  display: none;
}

.sidebar-section:not(.is-open) .sidebar-section-chevron {
  transform: rotate(-90deg);
}

/* Recent Tickers (Reddit-style RECENT list) */
.sidebar-recent-list {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.15rem 0.25rem;
}

.sidebar-recent-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.42rem 0.65rem;
  border-radius: 9999px;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background 0.15s ease, color 0.15s ease;
  box-sizing: border-box;
}

.sidebar-recent-item:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.sidebar-ticker-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-ticker-badge.is-blue { background: rgba(59, 130, 246, 0.15); color: #3b82f6; border: 1px solid rgba(59, 130, 246, 0.3); }
.sidebar-ticker-badge.is-purple { background: rgba(168, 85, 247, 0.15); color: #a855f7; border: 1px solid rgba(168, 85, 247, 0.3); }
.sidebar-ticker-badge.is-green { background: rgba(34, 197, 94, 0.15); color: #22c55e; border: 1px solid rgba(34, 197, 94, 0.3); }
.sidebar-ticker-badge.is-gray { background: rgba(156, 163, 175, 0.15); color: #9ca3af; border: 1px solid rgba(156, 163, 175, 0.3); }
.sidebar-ticker-badge.is-red { background: rgba(239, 68, 68, 0.15); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.3); }
.sidebar-ticker-badge.is-gold { background: rgba(234, 179, 8, 0.15); color: #eab308; border: 1px solid rgba(234, 179, 8, 0.3); }

.sidebar-recent-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
}

.sidebar-recent-sym {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}

.sidebar-recent-name {
  font-size: 0.66rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

body.sidebar-collapsed .sidebar-recent-list,
body.sidebar-collapsed .sidebar-recent-item {
  display: none !important;
}

/* Sidebar Footer Status */
.sidebar-footer {
  padding: 0.65rem 0.85rem;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
  background: color-mix(in srgb, var(--panel) 85%, var(--bg));
}

.sidebar-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
  font-weight: 500;
}

.sidebar-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
}

/* ── Collapsed Desktop Mode (64px Icon Rail) ─────────────────── */
@media (min-width: 769px) {
  body.sidebar-collapsed {
    --sidebar-width: 64px;
  }

  body.sidebar-collapsed .sidebar-nav-label,
  body.sidebar-collapsed .sidebar-section-title,
  body.sidebar-collapsed .sidebar-section-chevron,
  body.sidebar-collapsed .sidebar-footer,
  body.sidebar-collapsed .sidebar-tickers-grid {
    display: none !important;
  }

  body.sidebar-collapsed .sidebar-section-header {
    display: none !important;
  }

  body.sidebar-collapsed .sidebar-section:not(.is-open) .sidebar-section-content {
    display: none !important;
  }

  body.sidebar-collapsed .sidebar-nav-item {
    justify-content: center;
    padding: 0.52rem 0;
    width: 44px;
    margin: 0.18rem auto;
    border-radius: var(--radius-md);
  }

  body.sidebar-collapsed .sidebar-bot-dot {
    margin: 0;
    width: 10px;
    height: 10px;
  }

  body.sidebar-collapsed .sidebar-nav-item:hover::after {
    content: attr(data-title);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--panel);
    border: 1px solid var(--line);
    color: var(--text);
    padding: 0.35rem 0.65rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    font-family: var(--ui);
    white-space: nowrap;
    pointer-events: none;
    z-index: 1000;
    box-shadow: var(--shadow-md);
  }
}

/* ── Main Content Area Layout ────────────────────────────────── */
.app-main-wrap {
  margin-left: var(--sidebar-width);
  padding-top: var(--header-height);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

body.sidebar-collapsed .app-main-wrap {
  margin-left: 64px;
}

.desk-page-banner {
  padding: 1rem 2rem 0.8rem;
  border-bottom: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--panel) 40%, transparent);
  margin-bottom: 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
}

.desk-page-banner-content {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
  flex: 1 1 20rem;
}

.desk-page-title-wrap h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.desk-page-title-wrap .eyebrow {
  display: none;
}

.desk-page-banner .tagline {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  max-width: 650px;
  line-height: 1.35;
}

.desk-page-subnav-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.app-main-wrap #main {
  flex: 1 0 auto;
  max-width: 1560px;
  width: 100%;
  margin: 0 auto;
  padding: 0 1.5rem 2.5rem;
  box-sizing: border-box;
}

/* ── Mobile Off-Canvas Drawer (<= 768px) ─────────────────────── */
@media (max-width: 768px) {
  .app-sidebar {
    transform: translateX(-100%);
    width: 280px;
    max-width: 85vw;
    top: 0;
    z-index: 1100;
    box-shadow: var(--shadow-lg);
  }

  body.sidebar-open .app-sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 1050;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  }

  body.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .app-main-wrap {
    margin-left: 0 !important;
  }

  body.sidebar-collapsed .app-main-wrap {
    margin-left: 0 !important;
  }

  .header-create-btn .create-btn-label {
    display: none;
  }

  .header-create-btn {
    padding: 0.4rem;
    border-radius: 50%;
  }

  .desk-page-banner {
    padding: 0.85rem 1rem;
  }

  .app-main-wrap #main {
    padding: 0 0.85rem 2rem;
  }
}

@media (max-width: 480px) {
  .masthead-brand-name {
    display: none;
  }

  .app-header {
    padding: 0 0.75rem !important;
  }
}


/* ── Module: common/masthead-and-auth.css ─────────────────────────────────────── */

/**
 * Common Masthead, Auth Widget, Role Badges, and Search Bar
 * AlgoPaca Modular Stylesheet
 */

/* ── Masthead Auth & User Widget ───────────────────────────── */
.masthead-auth-widget {
  position: relative;
  display: inline-flex;
  align-items: center;
  z-index: 105;
}

.masthead-guest-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.masthead-auth-link {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  padding: 0.38rem 0.75rem;
  border-radius: var(--radius-md);
  transition: all 0.15s ease;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
}

.masthead-auth-link.is-login {
  color: var(--muted);
  border: 1px solid var(--line);
  background: var(--surface-soft);
}

.masthead-auth-link.is-login:hover {
  color: var(--text);
  border-color: var(--copper);
  background: rgba(212, 137, 76, 0.1);
}

.masthead-auth-link.is-signup {
  background: var(--copper);
  color: #120b05;
  font-weight: 700;
  border: 1px solid var(--copper);
}

.masthead-auth-link.is-signup:hover {
  background: var(--copper-deep);
  border-color: var(--copper-deep);
  transform: translateY(-1px);
}

.masthead-user-widget {
  position: relative;
  display: flex;
  align-items: center;
}

.masthead-user-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  width: 34px;
  height: 34px;
  min-width: 34px;
  min-height: 34px;
  background: color-mix(in srgb, var(--panel) 85%, transparent);
  border: 1.5px solid var(--line);
  border-radius: 50%;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
  font-family: var(--mono);
  overflow: hidden;
  position: relative;
}

.masthead-user-trigger:hover,
.masthead-user-trigger[aria-expanded="true"],
.masthead-user-trigger.is-active-page {
  border-color: var(--copper);
  background: var(--slate);
  box-shadow: 0 0 10px var(--glow);
}

.masthead-user-trigger:active {
  transform: scale(0.96);
}

.masthead-user-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--copper) 0%, var(--copper-deep) 100%);
  color: var(--copper-text, #0c1219);
  font-size: 0.74rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  overflow: hidden;
  position: relative;
}

.masthead-user-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

.masthead-user-avatar-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.74rem;
  font-weight: 700;
  color: inherit;
}

.masthead-user-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 275px;
  max-width: calc(100vw - 1.25rem);
  background: var(--panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 0.55rem;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  z-index: 200;
  animation: authFadeIn 0.15s ease-out;
  box-sizing: border-box;
}

.masthead-user-menu *,
.masthead-user-menu *::before,
.masthead-user-menu *::after {
  box-sizing: border-box;
}

.masthead-user-menu[hidden] {
  display: none;
}

.masthead-user-info {
  padding: 0.35rem 0.5rem 0.55rem;
  border-bottom: 1px solid var(--line);
}

.masthead-info-name {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 0.15rem;
  word-break: break-all;
}

.masthead-info-email {
  font-size: 0.7rem;
  color: var(--muted);
  font-family: var(--mono);
  margin: 0 0 0.3rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.masthead-info-role {
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--copper);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: inline-block;
}

/* Masthead Account Section */
.masthead-account-section {
  padding: 0.5rem 0.55rem;
  background: var(--surface-soft, rgba(255, 255, 255, 0.03));
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0.15rem 0 0.1rem;
}

.masthead-account-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.masthead-account-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.masthead-account-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.masthead-account-badge {
  font-family: var(--mono);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 0.1rem 0.35rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--copper) 18%, transparent);
  color: var(--copper);
  border: 1px solid color-mix(in srgb, var(--copper) 35%, transparent);
  line-height: 1.2;
}

.masthead-account-badge.is-live {
  background: color-mix(in srgb, var(--buy, #10b981) 18%, transparent);
  color: var(--buy, #10b981);
  border-color: color-mix(in srgb, var(--buy, #10b981) 35%, transparent);
}

.masthead-account-badge.is-offline {
  background: color-mix(in srgb, var(--muted) 15%, transparent);
  color: var(--muted);
  border-color: color-mix(in srgb, var(--line) 50%, transparent);
}

.masthead-account-refresh {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs, 4px);
  transition: color 0.15s ease, background 0.15s ease;
}

.masthead-account-refresh:hover {
  color: var(--copper);
  background: color-mix(in srgb, var(--copper) 12%, transparent);
}

.masthead-account-refresh.is-spinning svg {
  animation: spinAccount 0.8s linear infinite;
}

@keyframes spinAccount {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.masthead-account-primary {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
}

.masthead-account-equity-label {
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.masthead-account-equity-val-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.masthead-account-equity-val {
  font-family: var(--mono);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.masthead-account-pl-pill {
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.12rem 0.42rem;
  border-radius: 999px;
  line-height: 1.25;
  white-space: nowrap;
  flex-shrink: 0;
}

.masthead-account-pl-pill.is-positive {
  background: color-mix(in srgb, var(--buy, #10b981) 18%, transparent);
  color: var(--buy, #10b981);
  border: 1px solid color-mix(in srgb, var(--buy, #10b981) 35%, transparent);
}

.masthead-account-pl-pill.is-negative {
  background: color-mix(in srgb, var(--sell, #ef4444) 18%, transparent);
  color: var(--sell, #ef4444);
  border: 1px solid color-mix(in srgb, var(--sell, #ef4444) 35%, transparent);
}

.masthead-account-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  padding-top: 0.35rem;
  border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}

.masthead-account-metric {
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
}

.masthead-account-metric-label {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.masthead-account-metric-val {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.masthead-account-status-line {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.65rem;
  color: var(--muted);
  font-family: var(--ui);
  padding-top: 0.1rem;
}

.masthead-account-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}

.masthead-account-status-dot.is-active {
  background: var(--buy, #10b981);
  box-shadow: 0 0 6px color-mix(in srgb, var(--buy, #10b981) 60%, transparent);
}

.masthead-account-status-dot.is-offline {
  background: var(--muted);
}

.masthead-account-connect-row {
  padding-top: 0.15rem;
}

.masthead-account-connect-link {
  font-size: 0.68rem;
  color: var(--copper);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-weight: 500;
}

.masthead-account-connect-link:hover {
  text-decoration: underline;
}

.masthead-menu-item {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.55rem;
  width: 100%;
  padding: 0.45rem 0.55rem;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--ui);
  font-size: 0.82rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  min-height: auto;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
}

.masthead-menu-item:hover {
  background: var(--surface-soft);
  color: var(--text);
  transform: none;
}

.masthead-menu-item.is-active {
  background: color-mix(in srgb, var(--copper) 12%, transparent);
  color: var(--copper);
  font-weight: 600;
}

.masthead-menu-item.is-active svg {
  color: var(--copper);
}

.masthead-menu-item.is-logout {
  color: var(--sell);
}

.masthead-menu-item.is-logout:hover {
  background: color-mix(in srgb, var(--sell) 12%, transparent);
  color: var(--sell);
}

.masthead-info-role.is-admin-role {
  color: var(--cyan, #38bdf8);
  font-weight: 600;
}

.masthead-menu-item.is-admin-link {
  color: var(--cyan, #38bdf8);
}

.masthead-menu-item.is-admin-link:hover {
  background: color-mix(in srgb, var(--cyan, #38bdf8) 12%, transparent);
}

.masthead-menu-item.is-admin-link.is-active {
  background: color-mix(in srgb, var(--cyan, #38bdf8) 18%, transparent);
  color: var(--cyan, #38bdf8);
  font-weight: 600;
}

.masthead-menu-item.is-admin-link.is-active svg {
  color: var(--cyan, #38bdf8);
}

.masthead-menu-divider {
  height: 1px;
  background: var(--line);
  margin: 0.2rem 0;
}

.masthead-menu-item svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* Masthead User Menu - Terminal Theme Switcher */
.masthead-menu-theme-section {
  padding: 0.2rem 0.15rem 0.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  width: 100%;
}

.masthead-theme-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0 0.15rem;
}

.masthead-theme-header svg.masthead-theme-icon {
  width: 12.5px;
  height: 12.5px;
  color: var(--muted);
  flex-shrink: 0;
  opacity: 0.85;
}

.masthead-theme-title {
  font-family: var(--ui);
  font-size: 0.66rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  line-height: 1;
}

.masthead-theme-picker {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.35rem;
  width: 100%;
}

.masthead-theme-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.48rem 0.2rem 0.4rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-soft, rgba(255, 255, 255, 0.03));
  color: var(--muted);
  cursor: pointer;
  outline: none;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  min-height: auto;
  min-width: 0;
  width: 100%;
}

.masthead-theme-btn:hover {
  background: color-mix(in srgb, var(--copper) 8%, var(--surface-soft));
  border-color: color-mix(in srgb, var(--copper) 45%, var(--line));
  color: var(--text);
  transform: translateY(-1px);
}

.masthead-theme-btn:focus-visible {
  border-color: var(--copper);
  box-shadow: 0 0 0 2px var(--glow);
}

.masthead-theme-btn.is-active {
  border-color: color-mix(in srgb, var(--copper) 60%, transparent);
  color: var(--copper);
  background: color-mix(in srgb, var(--copper) 14%, var(--surface-soft));
  box-shadow: 0 0 10px var(--glow);
}

.masthead-theme-swatch {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.masthead-theme-swatch.obsidian {
  background: linear-gradient(135deg, #d4894c 0%, #b56a32 100%);
}

.masthead-theme-swatch.midnight {
  background: linear-gradient(135deg, #38bdf8 0%, #0284c7 100%);
}

.masthead-theme-swatch.emerald {
  background: linear-gradient(135deg, #3fbf8f 0%, #22996d 100%);
}

.masthead-theme-swatch.daylight {
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  border-color: rgba(37, 99, 235, 0.3);
}

.masthead-theme-btn.is-active .masthead-theme-swatch {
  transform: scale(1.1);
  box-shadow: 0 0 0 2px var(--panel), 0 0 0 3.5px var(--copper);
  border-color: transparent;
}

.masthead-theme-label {
  font-family: var(--ui);
  font-size: 0.67rem;
  font-weight: 500;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  color: inherit;
  letter-spacing: -0.01em;
}

.masthead-theme-btn.is-active .masthead-theme-label {
  color: var(--copper);
  font-weight: 600;
}

.bt-subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  /* Now a direct row of the `.masthead` grid, so spacing comes from its gap
     rather than a margin stacked on top of it. */
  margin-top: 0;
  padding-top: 0;
}

.bt-subnav-link {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--muted);
  padding: 0.35rem 0.15rem;
  margin-right: 1rem;
  border-bottom: 2px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.bt-subnav-link:hover {
  color: var(--text);
}

.bt-subnav-link.is-active {
  color: var(--copper);
  border-bottom-color: var(--copper);
}

@media (max-width: 768px) {
  .bt-subnav {
    display: flex;
    flex-wrap: nowrap;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 3px;
    gap: 3px;
    margin: 0.25rem 0 1rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .bt-subnav-link {
    flex: 1;
    text-align: center;
    padding: 0.5rem 0.35rem;
    margin-right: 0;
    border-bottom: none;
    border-radius: calc(var(--radius-md) - 3px);
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    white-space: nowrap;
  }

  .bt-subnav-link.is-active {
    background: color-mix(in srgb, var(--copper) 22%, transparent);
    color: var(--copper);
    font-weight: 700;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  }
}

.page[hidden] {
  display: none !important;
}


.alpaca-account-warning:not([hidden]) {
  margin: 0.75rem 0;
  padding: 0.75rem 1rem;
  border: 1px solid #d96b48;
  border-radius: 8px;
  background: #4a241c;
  color: #fff1e8;
  font-size: 0.9rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}


/* ── Module: common/forms-and-feedback.css ─────────────────────────────────────── */

/**
 * Common Form Controls, Buttons, Modals, and Toast Alerts
 * AlgoPaca Modular Stylesheet
 */

/* ── Forms & Nice Select ───────────────────────────────────────── */
/* Nice Select 2 — match desk form fields & fintech dark UI */
.nice-select,
.form .nice-select,
.history-filter-fields .nice-select,
.page-settings .nice-select,
.bt-detail-pick .nice-select,
.pos-sort-group .nice-select {
  float: none;
  clear: none;
  width: 100%;
  height: auto;
  min-height: 2.75rem;
  line-height: 1.35;
  padding: 0.65rem 2.2rem 0.65rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background-color: var(--input-bg);
  color: var(--text);
  font-family: var(--ui);
  font-size: 0.9rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0.01em;
  white-space: nowrap;
  display: flex;
  align-items: center;
  user-select: none;
  box-sizing: border-box;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.nice-select:hover,
.form .nice-select:hover,
.history-filter-fields .nice-select:hover,
.page-settings .nice-select:hover,
.bt-detail-pick .nice-select:hover,
.pos-sort-group .nice-select:hover {
  border-color: color-mix(in srgb, var(--copper) 65%, var(--line));
  background-color: color-mix(in srgb, var(--panel) 45%, var(--input-bg));
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.nice-select:active,
.nice-select:focus,
.nice-select.open,
.form .nice-select:active,
.form .nice-select:focus,
.form .nice-select.open,
.history-filter-fields .nice-select:active,
.history-filter-fields .nice-select:focus,
.history-filter-fields .nice-select.open,
.bt-detail-pick .nice-select:active,
.page-settings .nice-select:active,
.bt-detail-pick .nice-select:focus,
.page-settings .nice-select:focus,
.page-settings .nice-select.open,
.bt-detail-pick .nice-select.open,
.pos-sort-group .nice-select:active,
.pos-sort-group .nice-select:focus,
.pos-sort-group .nice-select.open {
  border-color: var(--copper);
  background-color: color-mix(in srgb, var(--panel) 65%, var(--input-bg));
  box-shadow: 0 0 0 2px var(--glow), 0 4px 16px rgba(0, 0, 0, 0.35);
  outline: none;
}

.nice-select:after,
.form .nice-select:after,
.history-filter-fields .nice-select:after,
.page-settings .nice-select:after,
.bt-detail-pick .nice-select:after,
.pos-sort-group .nice-select:after {
  content: "";
  display: block;
  position: absolute;
  right: 14px;
  top: 50%;
  width: 6px;
  height: 6px;
  border-bottom: 2px solid var(--muted);
  border-right: 2px solid var(--muted);
  transform: translateY(-70%) rotate(45deg);
  transform-origin: 66% 66%;
  pointer-events: none;
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.2s ease;
  margin-top: 0;
}

.nice-select:hover:after,
.form .nice-select:hover:after,
.history-filter-fields .nice-select:hover:after,
.page-settings .nice-select:hover:after,
.bt-detail-pick .nice-select:hover:after,
.pos-sort-group .nice-select:hover:after {
  border-bottom-color: var(--text);
  border-right-color: var(--text);
}

.nice-select.open:after,
.form .nice-select.open:after,
.history-filter-fields .nice-select.open:after,
.page-settings .nice-select.open:after,
.bt-detail-pick .nice-select.open:after,
.pos-sort-group .nice-select.open:after {
  transform: translateY(-30%) rotate(-135deg);
  border-bottom-color: var(--copper);
  border-right-color: var(--copper);
}

.nice-select.disabled,
.form .nice-select.disabled,
.history-filter-fields .nice-select.disabled,
.page-settings .nice-select.disabled,
.bt-detail-pick .nice-select.disabled,
.pos-sort-group .nice-select.disabled {
  opacity: 0.5;
  border-color: var(--line);
  color: var(--muted);
  cursor: not-allowed;
  pointer-events: none;
}

.nice-select .current,
.form .nice-select .current,
.history-filter-fields .nice-select .current,
.page-settings .nice-select .current,
.bt-detail-pick .nice-select .current,
.pos-sort-group .nice-select .current {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}

.nice-select .nice-select-dropdown,
.form .nice-select .nice-select-dropdown,
.history-filter-fields .nice-select .nice-select-dropdown,
.page-settings .nice-select .nice-select-dropdown,
.bt-detail-pick .nice-select .nice-select-dropdown,
.pos-sort-group .nice-select .nice-select-dropdown {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  width: 100%;
  min-width: 100%;
  margin-top: 0;
  background-color: color-mix(in srgb, var(--panel) 96%, transparent);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid color-mix(in srgb, var(--copper) 25%, var(--line));
  border-radius: var(--radius-md);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.04), 0 0 24px rgba(212, 137, 76, 0.08);
  max-height: min(18rem, 55vh);
  overflow-y: auto;
  overflow-x: hidden;
  box-sizing: border-box;
  z-index: 120;
  padding: 0.35rem;
  transform-origin: top center;
  transform: scale(0.98) translateY(-4px);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.18s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.18s ease;
}

.nice-select.open .nice-select-dropdown,
.form .nice-select.open .nice-select-dropdown,
.history-filter-fields .nice-select.open .nice-select-dropdown,
.page-settings .nice-select.open .nice-select-dropdown,
.bt-detail-pick .nice-select.open .nice-select-dropdown,
.pos-sort-group .nice-select.open .nice-select-dropdown {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

.nice-select:not(.open) .nice-select-dropdown {
  visibility: hidden !important;
  pointer-events: none !important;
}

.nice-select .list,
.form .nice-select .list,
.history-filter-fields .nice-select .list,
.page-settings .nice-select .list,
.bt-detail-pick .nice-select .list,
.pos-sort-group .nice-select .list {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Search box inside nice-select dropdown */
.nice-select .nice-select-search-box,
.form .nice-select .nice-select-search-box,
.history-filter-fields .nice-select .nice-select-search-box,
.page-settings .nice-select .nice-select-search-box,
.bt-detail-pick .nice-select .nice-select-search-box,
.pos-sort-group .nice-select .nice-select-search-box {
  box-sizing: border-box;
  width: calc(100% + 0.7rem);
  margin: -0.35rem -0.35rem 0.35rem -0.35rem;
  padding: 0.45rem 0.5rem;
  position: sticky;
  top: -0.35rem;
  z-index: 10;
  background-color: color-mix(in srgb, var(--panel) 98%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
  pointer-events: auto !important;
}

.nice-select .nice-select-search,
.form .nice-select .nice-select-search,
.history-filter-fields .nice-select .nice-select-search,
.page-settings .nice-select .nice-select-search,
.bt-detail-pick .nice-select .nice-select-search,
.pos-sort-group .nice-select .nice-select-search {
  box-sizing: border-box;
  width: 100%;
  height: 2.15rem;
  min-height: 2.15rem;
  line-height: 2.15rem;
  padding: 0 0.75rem 0 2rem;
  background-color: var(--input-bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238ba2c4' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 0.65rem center;
  background-size: 0.85rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.82rem;
  outline: none !important;
  pointer-events: auto !important;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.nice-select .nice-select-search:focus,
.form .nice-select .nice-select-search:focus,
.history-filter-fields .nice-select .nice-select-search:focus,
.page-settings .nice-select .nice-select-search:focus {
  border-color: var(--copper);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--copper) 25%, transparent);
}

.nice-select .nice-select-search::placeholder {
  color: var(--muted);
  opacity: 0.8;
}

.nice-select .nice-select-no-results {
  padding: 0.75rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  user-select: none;
  pointer-events: none;
}

/* Optgroup section header */
.nice-select .optgroup,
.form .nice-select .optgroup,
.history-filter-fields .nice-select .optgroup,
.page-settings .nice-select .optgroup {
  padding: 0.55rem 0.65rem 0.25rem;
  font-family: var(--ui);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  pointer-events: none;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.nice-select .optgroup:not(:first-child),
.form .nice-select .optgroup:not(:first-child) {
  margin-top: 0.35rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--line-soft);
}

/* Option items */
.nice-select .option,
.form .nice-select .option,
.history-filter-fields .nice-select .option,
.page-settings .nice-select .option,
.bt-detail-pick .nice-select .option,
.pos-sort-group .nice-select .option {
  min-height: 2.25rem;
  line-height: 1.35;
  padding: 0.48rem 0.65rem;
  color: var(--text);
  font-family: var(--ui);
  font-size: 0.86rem;
  font-weight: 500;
  white-space: normal;
  cursor: pointer;
  border-radius: calc(var(--radius-sm) - 2px);
  margin: 1px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.nice-select .option:hover,
.nice-select .option.focus,
.nice-select .option.selected.focus,
.form .nice-select .option:hover,
.form .nice-select .option.focus,
.form .nice-select .option.selected.focus,
.history-filter-fields .nice-select .option:hover,
.history-filter-fields .nice-select .option.focus,
.history-filter-fields .nice-select .option.selected.focus,
.bt-detail-pick .nice-select .option:hover,
.page-settings .nice-select .option:hover,
.bt-detail-pick .nice-select .option.focus,
.page-settings .nice-select .option.focus,
.page-settings .nice-select .option.selected.focus,
.bt-detail-pick .nice-select .option.selected.focus,
.pos-sort-group .nice-select .option:hover,
.pos-sort-group .nice-select .option.focus,
.pos-sort-group .nice-select .option.selected.focus {
  background-color: color-mix(in srgb, var(--copper) 14%, rgba(255, 255, 255, 0.04));
  color: var(--text);
}

.nice-select .option.selected,
.form .nice-select .option.selected,
.history-filter-fields .nice-select .option.selected,
.page-settings .nice-select .option.selected,
.bt-detail-pick .nice-select .option.selected,
.pos-sort-group .nice-select .option.selected {
  font-weight: 600;
  color: var(--copper);
  background-color: color-mix(in srgb, var(--copper) 18%, transparent);
}

.nice-select .option.disabled,
.form .nice-select .option.disabled,
.history-filter-fields .nice-select .option.disabled,
.page-settings .nice-select .option.disabled,
.bt-detail-pick .nice-select .option.disabled,
.pos-sort-group .nice-select .option.disabled {
  color: var(--muted);
  opacity: 0.55;
  cursor: not-allowed;
  font-size: 0.82rem;
}

/* Extra tags (e.g. [AI], [SMA], etc. badges) */
.nice-select .extra {
  float: right;
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.nice-tag {
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.25;
  display: inline-block;
}

/* Dropdown scrollbars */
.nice-select .nice-select-dropdown::-webkit-scrollbar,
.form .nice-select .nice-select-dropdown::-webkit-scrollbar,
.history-filter-fields .nice-select .nice-select-dropdown::-webkit-scrollbar,
.page-settings .nice-select .nice-select-dropdown::-webkit-scrollbar,
.bt-detail-pick .nice-select .nice-select-dropdown::-webkit-scrollbar,
.pos-sort-group .nice-select .nice-select-dropdown::-webkit-scrollbar {
  width: 5px;
}

.nice-select .nice-select-dropdown::-webkit-scrollbar-track,
.form .nice-select .nice-select-dropdown::-webkit-scrollbar-track {
  background: transparent;
}

.nice-select .nice-select-dropdown::-webkit-scrollbar-thumb,
.form .nice-select .nice-select-dropdown::-webkit-scrollbar-thumb,
.history-filter-fields .nice-select .nice-select-dropdown::-webkit-scrollbar-thumb,
.page-settings .nice-select .nice-select-dropdown::-webkit-scrollbar-thumb,
.bt-detail-pick .nice-select .nice-select-dropdown::-webkit-scrollbar-thumb,
.pos-sort-group .nice-select .nice-select-dropdown::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 999px;
}

.nice-select .nice-select-dropdown::-webkit-scrollbar-thumb:hover,
.form .nice-select .nice-select-dropdown::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

.form input:focus-visible,
.form select:focus-visible,
.form textarea:focus-visible,
button:focus-visible,
a.button:focus-visible {
  border-color: var(--copper);
  box-shadow: 0 0 0 2px rgba(212, 137, 76, 0.35);
  outline: none;
}

.form input:disabled,
.form select:disabled,
.form textarea:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.form select.hidden-select,
.history-filter-fields select.hidden-select,
.page-settings select.hidden-select,
.bt-detail-pick select.hidden-select {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
}

.field-help {
  grid-column: 1 / -1;
  margin: 0 0 0.35rem;
  font-family: var(--ui);
  font-size: 0.7rem;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
  line-height: 1.4;
}

.watch-chips {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.watch-chips[hidden] {
  display: none;
}

.watch-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 2rem;
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--slate);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.watch-chip:hover {
  border-color: var(--copper);
  color: var(--copper);
}

.watch-chip.is-featured {
  background: color-mix(in srgb, var(--copper) 18%, var(--slate));
  border-color: color-mix(in srgb, var(--copper) 55%, var(--line));
}

#featured-warn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  flex-wrap: wrap;
}

#featured-warn[hidden] {
  display: none;
}

#featured-warn .ghost {
  flex-shrink: 0;
}

.field-help.invalid {
  color: var(--error);
}

.field-help.warn {
  color: var(--warn);
}

/* Quantity / Size field: label + available + #/$ unit pill on one row, amount below */
.manual-qty-field {
  display: grid;
  gap: 0.4rem;
  min-width: 0;
}

.manual-qty-field[hidden] {
  display: none;
}

.field-group > .manual-qty-field {
  grid-column: 1 / -1;
}

.qty-field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.qty-field-copy {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  min-width: 0;
}

.qty-field-label {
  display: inline;
  margin: 0;
  font-family: var(--ui);
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text);
}

.qty-field-avail {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--ui);
  font-size: 0.85rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.qty-field-avail.is-empty {
  color: var(--warn);
}

.qty-unit-toggle {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  padding: 0.12rem;
  gap: 0.1rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--line) 70%, var(--panel));
}

.qty-unit {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 1.55rem;
  min-height: 1.55rem;
  width: 1.55rem;
  height: 1.55rem;
  margin: 0;
  padding: 0;
  border-radius: 999px;
  background: transparent;
  font-family: var(--mono);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
  gap: 0;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

@media (pointer: coarse) {
  .qty-unit {
    min-width: 1.95rem;
    min-height: 1.95rem;
    width: 1.95rem;
    height: 1.95rem;
    font-size: 0.84rem;
  }
}

.qty-unit input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.qty-unit:hover {
  color: var(--text);
}

.qty-unit:has(input:checked) {
  background: var(--copper);
  color: var(--ink);
}

.qty-unit:has(input:focus-visible) {
  outline: 2px solid var(--copper);
  outline-offset: 2px;
}

.qty-unit.is-disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

/* Tooltip on quantity unit items */
.qty-unit[data-tooltip] {
  position: relative;
}

.qty-unit[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  padding: 0.25rem 0.55rem;
  border-radius: 4px;
  border: 1px solid color-mix(in srgb, var(--line) 85%, transparent);
  background: color-mix(in srgb, var(--slate) 95%, #000);
  color: var(--text);
  font-family: var(--ui);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  max-width: 14rem;
  width: max-content;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.16s ease, transform 0.16s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.16s ease;
  z-index: 50;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.qty-unit[data-tooltip]::before {
  content: "";
  position: absolute;
  bottom: calc(100% + 3px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  border-width: 5px 4.5px 0 4.5px;
  border-style: solid;
  border-color: color-mix(in srgb, var(--line) 85%, transparent) transparent transparent transparent;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.16s ease, transform 0.16s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.16s ease;
  z-index: 51;
}

.qty-unit:last-child[data-tooltip]::after {
  left: auto;
  right: -0.25rem;
  transform: translateY(4px);
}

.qty-unit:last-child[data-tooltip]::before {
  left: auto;
  right: 0.7rem;
  transform: translateY(4px);
}

.qty-unit[data-tooltip]:hover::after,
.qty-unit[data-tooltip]:hover::before,
.qty-unit[data-tooltip]:focus-within::after,
.qty-unit[data-tooltip]:focus-within::before {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.qty-unit:last-child[data-tooltip]:hover::after,
.qty-unit:last-child[data-tooltip]:hover::before,
.qty-unit:last-child[data-tooltip]:focus-within::after,
.qty-unit:last-child[data-tooltip]:focus-within::before {
  transform: translateY(0);
}

.qty-unit[data-tooltip=""]::after,
.qty-unit[data-tooltip=""]::before {
  display: none;
}

@media (pointer: coarse) {
  .qty-unit[data-tooltip]::after,
  .qty-unit[data-tooltip]::before {
    display: none;
  }
}

.qty-field-input {
  min-width: 0;
}

.qty-field-input[hidden] {
  display: none;
}

/* Price & quantity input shell */
.price-input-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  min-height: 2.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--input-bg, var(--panel-bg));
  overflow: hidden;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.price-input-shell:hover {
  border-color: color-mix(in srgb, var(--copper) 35%, var(--line));
}

.price-input-shell:focus-within {
  border-color: var(--copper);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--copper) 16%, transparent);
}

.price-input-shell:has(input[aria-invalid="true"]) {
  border-color: var(--error);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--error) 35%, transparent);
}

.price-input-shell:has(input:disabled) {
  opacity: 0.55;
  pointer-events: none;
}

.price-input-shell.is-readonly {
  background: color-mix(in srgb, var(--panel-bg, #101823) 80%, transparent);
  border-style: dashed;
}

.form .price-input-shell input[type="number"],
.price-input-shell input[type="number"] {
  width: 100%;
  min-width: 0;
  min-height: 2.75rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  padding: 0.55rem 0.75rem;
  color: var(--text);
  font-family: var(--mono);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: none;
  font-variant-numeric: tabular-nums;
  appearance: textfield;
  -webkit-appearance: textfield;
}

.price-input-shell input[type="number"]:focus,
.price-input-shell input[type="number"]:focus-visible {
  border: 0;
  box-shadow: none;
  outline: none;
}

.price-input-shell input[type="number"]::-webkit-inner-spin-button,
.price-input-shell input[type="number"]::-webkit-outer-spin-button {
  appearance: none;
  margin: 0;
}

.price-input-shell input[type="number"]:disabled {
  opacity: 1;
  cursor: not-allowed;
}

.price-fill-group {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.12rem 0.25rem 0.12rem 0.35rem;
  margin: 0.15rem 0.2rem 0.15rem 0;
  border-left: 1px solid var(--line);
  text-transform: none;
  letter-spacing: 0;
}

.price-fill-group .ghost.small {
  min-height: 1.55rem;
  padding: 0.12rem 0.38rem;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  border-radius: 3px;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

@media (pointer: coarse) {
  .price-fill-group {
    padding: 0.18rem 0.35rem 0.18rem 0.45rem;
    gap: 0.3rem;
  }

  .price-fill-group .ghost.small {
    min-height: 2.1rem;
    padding: 0.2rem 0.55rem;
    font-size: 0.72rem;
  }
}

@media (max-width: 48rem) {
  .price-fill-group [data-i18n="use_mid"],
  .price-fill-group [data-i18n="use_mark"] {
    display: none !important;
  }
}

.qty-fill-group .ghost.small.is-active {
  border-color: var(--copper);
  background: color-mix(in srgb, var(--copper) 18%, var(--panel));
  color: var(--text);
}

/* Date fields — same shell language as size inputs. Native date chrome
   (mm/dd/yyyy + OS calendar glyph) fights the desk, so the indicator is
   replaced with a stroke icon and the value is set in Plex Mono. */
.date-field-shell {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  min-height: 2.25rem;
  padding: 0 0.5rem 0 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  overflow: hidden;
  cursor: text;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.date-field-shell:hover {
  border-color: color-mix(in srgb, var(--copper) 35%, var(--line));
}

.date-field-shell:focus-within {
  border-color: var(--copper);
  box-shadow: 0 0 0 3px rgba(212, 137, 76, 0.16);
}

.date-field-shell.is-invalid {
  border-color: color-mix(in srgb, var(--sell) 70%, var(--line));
}

.date-field-shell.is-invalid:focus-within {
  border-color: var(--sell);
  box-shadow: 0 0 0 3px rgba(227, 93, 93, 0.18);
}

.date-field-icon {
  display: block;
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  color: var(--muted);
  pointer-events: none;
  transition: color 0.18s ease;
}

.date-field-shell:hover .date-field-icon,
.date-field-shell:focus-within .date-field-icon,
.date-field-shell.is-filled .date-field-icon {
  color: var(--copper);
}

.date-field-shell.is-invalid .date-field-icon {
  color: var(--sell);
}

/* Prefixed with `.form` so these beat the generic `.form input[type="date"]`
   block further down the file — same trap as the size-input shell. */
.form .date-field-shell input[type="date"],
.date-field-shell input[type="date"] {
  width: 100%;
  min-width: 0;
  min-height: 1.85rem;
  margin: 0;
  padding: 0.2rem 0.1rem 0.2rem 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color-scheme: dark;
  cursor: pointer;
  touch-action: manipulation;
}

.date-field-shell.is-filled input[type="date"] {
  color: var(--text);
}

.form .date-field-shell input[type="date"]:focus-visible,
.date-field-shell input[type="date"]:focus-visible {
  border-color: transparent;
  box-shadow: none;
}

.date-field-shell input[type="date"]::-webkit-calendar-picker-indicator {
  display: none;
  -webkit-appearance: none;
}

.date-field-shell input[type="date"]::-webkit-datetime-edit {
  padding: 0;
  width: 100%;
}

.date-field-shell input[type="date"]::-webkit-datetime-edit-fields-wrapper {
  padding: 0;
}

.date-field-shell input[type="date"]::-webkit-datetime-edit-text {
  color: var(--muted);
  padding: 0 0.12em;
}

.date-field-shell input[type="date"]::-webkit-datetime-edit-month-field:focus,
.date-field-shell input[type="date"]::-webkit-datetime-edit-day-field:focus,
.date-field-shell input[type="date"]::-webkit-datetime-edit-year-field:focus {
  background: rgba(212, 137, 76, 0.22);
  color: var(--text);
  outline: none;
  border-radius: 0.2rem;
}

.date-field-shell.is-enhanced {
  position: relative;
  cursor: pointer;
  user-select: none;
}

.date-field-trigger {
  display: none;
}

.date-field-shell.is-enhanced .date-field-trigger {
  display: flex;
  align-items: center;
  width: 100%;
  min-width: 0;
  min-height: 1.85rem;
  margin: 0;
  padding: 0.2rem 0.1rem 0.2rem 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  text-align: left;
  cursor: pointer;
  transform: none;
}

.date-field-shell.is-enhanced .date-field-trigger:hover,
.date-field-shell.is-enhanced .date-field-trigger:focus-visible,
button.date-field-trigger:hover:not(:disabled) {
  transform: none;
  border-color: transparent;
  box-shadow: none;
  outline: none;
}

.date-field-value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.date-field-value.is-placeholder {
  color: var(--muted);
  font-weight: 400;
}

.date-field-shell.is-enhanced input[type="date"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  pointer-events: none;
}

.date-field-shell.is-open {
  border-color: var(--copper);
  box-shadow: 0 0 0 3px rgba(212, 137, 76, 0.16);
}

/* Same box as `.date-field-shell`. `button.ghost` is 36px and more specific
   than a lone class, so this selector has to outrank it. */
button.ghost.date-range-apply {
  align-self: end;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.25rem;
  height: 2.25rem;
  padding: 0 0.85rem;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  border-color: color-mix(in srgb, var(--copper) 42%, var(--line));
  background: rgba(212, 137, 76, 0.08);
}

button.ghost.date-range-apply:hover,
button.ghost.date-range-apply:focus-visible {
  border-color: var(--copper);
  background: rgba(212, 137, 76, 0.16);
}

/* Note: Date picker popover styles have been modularized into /static/css/desk-shell.css for device-specific loading */

.form-error {
  margin: 0;
  padding: 0.65rem 0.75rem;
  border: 1px solid rgba(227, 93, 93, 0.45);
  border-radius: var(--radius-sm);
  background: rgba(90, 38, 38, 0.35);
  color: var(--error-soft);
  font-size: 0.85rem;
  line-height: 1.4;
}

.form .check {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.95rem;
  color: var(--text);
  font-family: var(--ui);
  cursor: pointer;
  min-height: 44px;
  padding: 0.35rem 0;
}

/* Every `.check` control on the desk is a checkbox (no radios), so the box can
   be drawn from scratch — the native dark-mode square reads as a disabled
   placeholder next to the copper accents around it. */
.form .check input {
  width: 1.2rem;
  height: 1.2rem;
  margin: 0.1rem 0 0;
  flex-shrink: 0;
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid color-mix(in srgb, var(--line) 80%, var(--text));
  border-radius: 0.3rem;
  background: var(--input-bg) no-repeat center / 0.8rem 0.8rem;
  cursor: pointer;
  transition: border-color 0.18s ease, background-color 0.18s ease;
}

.form .check:hover input:not(:checked) {
  border-color: color-mix(in srgb, var(--copper) 55%, var(--line));
}

.form .check input:checked {
  border-color: var(--copper);
  background-color: var(--copper);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230c1219' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 12.5l5.5 5.5L20 6.5'/%3E%3C/svg%3E");
}

.form .check input:focus-visible {
  outline: 2px solid var(--copper);
  outline-offset: 2px;
}

.form .check input:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

/* Toggles inside a bordered group read as loose text next to the framed
   inputs above them — give them a surface so they land as controls. */
.field-group > .check,
.field-group > .day-only > .check,
#metals-strategy-options > .check,
#bt-metals-options > .check {
  padding: 0.6rem 0.75rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  transition: border-color 0.18s ease, background 0.18s ease;
}

.field-group > .check:hover,
.field-group > .day-only > .check:hover,
#metals-strategy-options > .check:hover,
#bt-metals-options > .check:hover {
  border-color: color-mix(in srgb, var(--copper) 30%, transparent);
  background: var(--line-soft);
}

.field-group > .check:focus-within,
.field-group > .day-only > .check:focus-within,
#metals-strategy-options > .check:focus-within,
#bt-metals-options > .check:focus-within {
  border-color: var(--copper);
}

.field-group > .check:has(input:checked),
.field-group > .day-only > .check:has(input:checked),
#metals-strategy-options > .check:has(input:checked),
#bt-metals-options > .check:has(input:checked) {
  border-color: color-mix(in srgb, var(--copper) 45%, transparent);
  background: rgba(212, 137, 76, 0.07);
}

#metals-strategy-options,
#bt-metals-options {
  grid-column: 1 / -1;
  width: 100%;
}

.form .check strong {
  display: block;
  font-weight: 700;
}

.check-desc {
  display: block;
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.field-pair-row > label {
  min-width: 0;
  /* Top-align the columns: when the size control wraps its unit rail onto a
     second line, a stretched neighbour would blow its input up to match. */
  align-self: start;
}

.manual-form > .panel-hint {
  margin: 0 0 0.75rem;
}

.manual-actions {
  display: flex;
  gap: 0.55rem;
  margin-top: 0.35rem;
}

.manual-actions .primary {
  flex: 1;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

button,
a.button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: 0;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--ui);
  font-weight: 700;
  font-size: 0.88rem;
  min-height: 38px;
  padding: 0.55rem 0.95rem;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
  box-sizing: border-box;
  line-height: 1.2;
  user-select: none;
  white-space: nowrap;
}

button svg,
a.button svg,
.btn svg {
  flex-shrink: 0;
}

/* Empty-state CTAs are anchors with button classes. Without this they keep
   the UA underline and miss the filled/outlined chrome that real <button>s get. */
a.button,
a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  text-decoration: none;
  line-height: 1.2;
}

button:hover:not(:disabled),
a.button:hover,
.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:disabled:not(.is-loading),
.btn:disabled:not(.is-loading),
.btn.is-disabled:not(.is-loading) {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

button.is-loading,
.btn.is-loading,
button.is-loading:disabled,
.btn.is-loading:disabled,
.btn-primary.is-loading,
.btn-primary:disabled.is-loading {
  opacity: 0.92;
  cursor: wait;
  pointer-events: none;
  filter: none;
}

button.primary,
a.button.primary,
.btn-primary {
  background: linear-gradient(180deg, var(--copper) 0%, var(--copper-deep) 100%);
  color: var(--copper-text, #0c1219);
  border: 1px solid var(--copper);
  font-weight: 700;
  box-shadow: 0 2px 8px var(--glow);
}

button.primary:hover:not(:disabled),
button.primary:focus-visible,
a.button.primary:hover,
a.button.primary:focus-visible,
.btn-primary:hover:not(:disabled),
.btn-primary:focus-visible {
  background: linear-gradient(180deg, color-mix(in srgb, var(--copper) 85%, white 15%) 0%, var(--copper) 100%);
  border-color: color-mix(in srgb, var(--copper) 85%, white 15%);
  color: var(--copper-text, #0c1219);
  box-shadow: 0 4px 14px var(--glow);
}

button.secondary,
.btn-secondary {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

button.secondary:hover:not(:disabled),
.btn-secondary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--text) 8%, transparent);
  border-color: var(--copper);
  color: var(--text);
}

button.copper {
  background: var(--copper);
  color: var(--copper-text, #0c1219);
}

button.copper:hover:not(:disabled) {
  background: var(--copper-deep);
}

button.danger,
.btn-danger {
  background: color-mix(in srgb, var(--sell) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--sell) 40%, transparent);
  color: var(--sell);
}

button.danger:hover:not(:disabled),
.btn-danger:hover:not(:disabled) {
  background: color-mix(in srgb, var(--sell) 25%, transparent);
  border-color: var(--sell);
  color: var(--sell);
  box-shadow: 0 0 12px color-mix(in srgb, var(--sell) 25%, transparent);
}

button.ghost,
a.ghost,
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 0.4rem 0.7rem;
  font-size: 0.8rem;
  min-height: 36px;
}

button.ghost:hover:not(:disabled),
a.ghost:hover,
.btn-ghost:hover:not(:disabled) {
  background: var(--surface-soft);
  border-color: var(--copper);
  color: var(--text);
}

.btn-sm {
  min-height: 32px;
  height: 32px;
  padding: 0 0.75rem;
  font-size: 0.78rem;
  gap: 0.35rem;
}

.btn-xs {
  min-height: 26px;
  height: 26px;
  padding: 0 0.5rem;
  font-size: 0.72rem;
  gap: 0.25rem;
}

/* Compact `a.ghost` is for toolbar chips. `a.button.ghost` is a full-size
   secondary next to `a.button.primary`, so it has to keep the same padding. */
a.button.ghost {
  padding: 0.7rem 0.95rem;
  font-size: 0.92rem;
  min-height: 44px;
  color: var(--text);
  border-color: color-mix(in srgb, var(--text) 28%, var(--line));
  background: color-mix(in srgb, var(--text) 4%, transparent);
}

a.button.ghost:hover,
a.button.ghost:focus-visible {
  color: var(--text);
  border-color: var(--copper);
  background: color-mix(in srgb, var(--copper) 12%, transparent);
}

button.ghost.ghost-danger {
  color: var(--sell);
  border-color: color-mix(in srgb, var(--sell) 42%, var(--line));
}

button.ghost.ghost-danger:hover,
button.ghost.ghost-danger:focus-visible {
  color: var(--sell);
  border-color: var(--sell);
}

.loop-state {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: inherit;
  line-height: 1.4;
}

.history-panel .history-list {
  max-height: none;
  overflow: visible;
  display: grid;
  gap: 0.65rem;
  padding-right: 0.15rem;
}

/* A class-level `display: grid` outranks the UA [hidden] rule, so say it here —
   the desk list is hidden by attribute whenever Source is Alpaca-only. */
.history-panel .history-list[hidden] {
  display: none;
}

.history-empty {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.5;
  padding: 0.85rem 0.15rem 0.55rem;
}

.history-empty-lead {
  margin: 0 0 0.25rem;
  color: var(--text);
  font-size: 0.86rem;
}

.history-empty-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  margin-top: 0.55rem;
}

.history-empty-actions a {
  color: var(--copper);
}



/* ── Module: common/components-and-tape.css ─────────────────────────────────────── */

/**
 * Common Live Tape, Media Queries, and Date Pickers
 * AlgoPaca Modular Stylesheet
 */

/* ── Global Media Queries & Motion ────────────────────────────── */
@media (max-width: 1100px) {
  .history-layout {
    grid-template-columns: 1fr;
  }

  /* Stacked, the tape is no longer a column beside anything — let it run. */
  .history-console,
  .fills-panel {
    position: static;
    max-height: none;
  }

  .fills-panel .history-list {
    overflow-y: visible;
    max-height: none;
  }

  .fills-panel .history-list-head {
    display: grid;
  }

  .fills-panel .history-row-top {
    grid-template-columns: 13.5rem auto minmax(0, 1fr) auto;
  }

  .fills-panel .history-time {
    grid-column: auto;
    white-space: nowrap;
  }
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .console {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .signal-wall {
    min-height: auto;
    padding: 1.35rem;
  }

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

  .actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .actions .primary,
  .actions #btn-loop {
    grid-column: 1 / -1;
    margin-left: 0;
  }

  .history-row-top {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .history-time {
    grid-column: 1 / -1;
    white-space: normal;
  }

  .history-price {
    grid-column: auto;
  }

  .history-filter-fields,
  .history-custom-range,
  .date-range,
  .pnl-summary {
    grid-template-columns: 1fr;
  }

  .date-range-span {
    display: none;
  }

  .date-range-apply {
    width: 100%;
    justify-self: stretch;
  }

  .pnl-tile {
    grid-template-rows: auto auto auto;
  }

  .history-chart-wrap {
    height: 11rem;
  }

  .history-list-head,
  .fills-panel .history-list-head {
    display: none;
  }

  .fills-panel .history-row-top {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .fills-panel .history-time {
    grid-column: 1 / -1;
    white-space: normal;
  }

  .history-page-panel .panel-head-actions {
    margin-left: 0;
    flex-wrap: wrap;
  }

  .masthead-top {
    align-items: flex-start;
  }

  .masthead-search {
    flex: 1 1 240px;
    max-width: 100%;
  }

  .masthead-right {
    /* `flex-basis: 100%` rather than `width: 100%`: a percentage width here
       resolves against a container that is itself being sized by this
       content, and the cycle makes the row measure at max-content. */
    flex: 1 0 100%;
    min-width: 0;
    padding-top: 0;
  }

  .desk-nav {
    flex: 1 1 auto;
    min-width: 0;
  }

  .lang-switcher {
    flex: none;
  }

  .watch-head,
  .watch-row {
    grid-template-columns:
      minmax(3.8rem, 5rem)
      2.9rem
      minmax(2.5rem, 3.75rem)
      minmax(0, 1fr);
    gap: 0.3rem 0.4rem;
    font-size: 0.7rem;
  }

  .watch-px {
    display: none;
  }
}

@media (max-width: 520px) {
  .app {
    padding-top: 1.25rem;
  }

  .field-group,
  .field-pair-row {
    grid-template-columns: 1fr;
  }

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

  .masthead h1 {
    font-size: clamp(1.9rem, 10vw, 2.6rem);
  }

  .masthead-logo-img {
    width: 40px;
    height: 40px;
  }

  .masthead-brand-header {
    gap: 0.75rem;
  }

  .masthead {
    padding-bottom: 1.1rem;
  }

  .tagline {
    font-size: 0.92rem;
  }

  /* Stacked at this width, so the dropdowns get the full row to open under
     rather than being pinned beside the language control. */
  .masthead-right {
    flex-wrap: wrap;
  }

  .desk-nav {
    flex: 1 0 100%;
  }

  /* Stays compact on its own row rather than stretching the full width —
     it is a set-once control, not a primary action. */
  .lang-switcher {
    margin-top: 0.15rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Desk Live Tape & History ─────────────────────────────────── */

.history-session {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-bg);
  overflow: hidden;
}

.history-session[data-status="running"] {
  border-color: rgba(212, 137, 76, 0.55);
  box-shadow: inset 0 0 0 1px rgba(212, 137, 76, 0.12);
}

.history-session-head {
  padding: 0.55rem 0.7rem 0.5rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.history-session-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem 0.65rem;
  font-family: var(--mono);
  font-size: 0.78rem;
}

.history-session-id {
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.history-session-status {
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.12rem 0.4rem;
  border-radius: 0.3rem;
  border: 1px solid var(--line);
  color: var(--muted);
}

.history-session-status.running {
  color: #1a1008;
  background: var(--copper);
  border-color: var(--copper);
}

.history-session-status.stopped,
.history-session-status.done {
  color: var(--muted);
}

.history-session-preset {
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: var(--copper);
  border: 1px solid rgba(212, 137, 76, 0.35);
  border-radius: 0.3rem;
  padding: 0.1rem 0.4rem;
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-session-time {
  color: var(--copper);
  font-variant-numeric: tabular-nums;
  margin-left: auto;
}

.history-session-meta {
  margin-top: 0.3rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.03em;
  color: var(--muted);
  line-height: 1.35;
}

.history-session-results {
  display: grid;
  gap: 0;
}

.history-session-empty {
  padding: 0.7rem 0.7rem;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.74rem;
}

.history-row {
  border: 0;
  border-top: 1px solid rgba(42, 56, 76, 0.4);
  border-left: 2px solid transparent;
  border-radius: 0;
  padding: 0.5rem 0.7rem;
  background: transparent;
}

.history-row.is-error {
  background: rgba(227, 93, 93, 0.06);
}

.history-row[data-signal="buy"] {
  border-left-color: var(--buy);
}

.history-row[data-signal="sell"] {
  border-left-color: var(--sell);
}

.history-row[data-signal="hold"] {
  border-left-color: var(--hold);
}

.history-row[data-signal="error"] {
  border-left-color: var(--sell);
}

.history-row[data-signal="split"] {
  border-left-color: var(--violet, #a78bfa);
}

.history-row-top {
  display: grid;
  grid-template-columns: minmax(13.5rem, max-content) auto minmax(0, 1fr) auto;
  gap: 0.4rem 0.55rem;
  align-items: baseline;
  font-family: var(--mono);
  font-size: 0.78rem;
}

.history-time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.history-signal {
  font-weight: 600;
  letter-spacing: 0.06em;
}

.history-signal.buy { color: var(--buy); }

.history-signal.sell { color: var(--sell); }

.history-signal.short { color: var(--sell); }

.history-signal.cover { color: var(--buy); }

.history-signal.hold { color: var(--hold); }

.history-signal.error { color: var(--sell); }

.history-signal.split { color: var(--violet, #a78bfa); }

.history-symbol {
  color: var(--text);
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-symbol-opt {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  flex-wrap: wrap;
}

.history-opt-root {
  font-weight: 700;
  color: var(--text);
}

.history-opt-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.08rem 0.4rem;
  border-radius: 0.3rem;
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  line-height: 1.25;
  text-transform: uppercase;
  vertical-align: middle;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.history-opt-badge.call {
  background: rgba(63, 191, 143, 0.12);
  color: var(--buy);
  border: 1px solid rgba(63, 191, 143, 0.38);
}

.history-opt-badge.put {
  background: rgba(227, 93, 93, 0.12);
  color: var(--sell);
  border: 1px solid rgba(227, 93, 93, 0.38);
}

.history-opt-badge .opt-tag-type {
  font-weight: 700;
  letter-spacing: 0.05em;
}

.history-opt-badge .opt-tag-strike {
  color: var(--text);
}

.history-opt-badge .opt-tag-dot {
  opacity: 0.45;
  font-size: 0.58rem;
}

.history-opt-badge .opt-tag-exp {
  opacity: 0.88;
  font-weight: 500;
  font-size: 0.62rem;
}

.history-flag-opt {
  color: var(--copper);
  background: rgba(212, 137, 76, 0.12);
  border: 1px solid rgba(212, 137, 76, 0.35);
  padding: 0.05rem 0.32rem;
  border-radius: 0.25rem;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  display: inline-block;
}

.history-price {
  color: var(--copper);
  font-variant-numeric: tabular-nums;
}

.history-row-meta {
  margin-top: 0.28rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.history-reason {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.log-heading {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  min-width: 0;
}

.log-count {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  color: var(--copper);
  font-variant-numeric: tabular-nums;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.manual-panel:not(.is-open),
.strategy-panel:not(.is-open) {
  padding-bottom: 0.85rem;
}

.manual-panel .panel-head,
.strategy-panel .panel-head {
  margin-bottom: 0;
}

.manual-panel.is-open .panel-head,
.strategy-panel.is-open .panel-head {
  margin-bottom: 0.85rem;
}

.panel-head-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-left: auto;
}

.manual-panel .manual-form[hidden],
.strategy-panel .strategy-body[hidden] {
  display: none;
}

.field-pair-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  grid-column: 1 / -1;
  width: 100%;
  min-width: 0;
}

/* Positions-page rules live in positions.css. What sat here was an earlier
   naming generation (.pos-sizing-*, .pos-preview-item, .pos-range-slider …)
   that the page markup never adopted, so it styled nothing while the classes
   actually in use went undesigned. */

.btn-danger {
  background: var(--danger, #e35d5d);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md, 6px);
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.btn-danger:hover:not(:disabled) {
  opacity: 0.9;
}

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

/* Analysis on the left, the fill tape on the right — the fills are a running
   log you scan while reading the numbers, not a footnote below them. */
.history-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 1.25rem;
  align-items: start;
}

/* A class-level `display: grid` outranks the UA [hidden] rule, so say it here. */
.history-console[hidden] {
  display: none;
}

/* Desk-only view: no tape, so the analysis column takes the full width. */
.history-layout.is-single {
  grid-template-columns: minmax(0, 1fr);
}

.range-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.chip {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  min-height: 2.5rem;
  min-width: 2.75rem;
  cursor: pointer;
}

.chip:hover {
  color: var(--text);
  border-color: rgba(212, 137, 76, 0.45);
}

.chip.is-active {
  color: var(--ink);
  background: var(--copper);
  border-color: var(--copper);
}

/* A stale number reads as a current one. Blur the figures specifically while
   a refresh is in flight, so nobody trades off the previous range's P&L. */
.pnl-summary.is-stale strong {
  filter: blur(4px);
  opacity: 0.7;
  transition: filter 0.12s ease;
}

.pnl-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 0 0 0.75rem;
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.pnl-summary strong {
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.pnl-summary strong.pos { color: var(--buy); }

.pnl-summary strong.neg { color: var(--sell); }

.symbol-pnl-val {
  font-variant-numeric: tabular-nums;
}

.symbol-pnl-val.pos { color: var(--buy); }

.symbol-pnl-val.neg { color: var(--sell); }

.history-day-pnl {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.history-day-pnl.pos { color: var(--buy); }

.history-day-pnl.neg { color: var(--sell); }

/* Each row carries its own highlight colour so the hover state speaks the
   tape's existing language — a buy glows green, a sell red. */
.history-row {
  --row-tint: rgba(212, 137, 76, 0.07);
  --row-rail: var(--copper);
  position: relative;
  transition:
    background-color 0.14s ease,
    box-shadow 0.14s ease;
}

.history-row[data-signal="buy"] {
  --row-tint: rgba(63, 191, 143, 0.08);
  --row-rail: var(--buy);
}

.history-row[data-signal="sell"],
.history-row[data-signal="error"] {
  --row-tint: rgba(227, 93, 93, 0.07);
  --row-rail: var(--sell);
}

.history-row[data-signal="hold"] {
  --row-tint: rgba(139, 154, 171, 0.08);
  --row-rail: var(--hold);
}

.history-row[data-signal="split"] {
  --row-tint: rgba(167, 139, 250, 0.08);
  --row-rail: var(--violet, #a78bfa);
}

.history-flag-split {
  color: var(--violet, #a78bfa);
  background: rgba(167, 139, 250, 0.12);
  border-color: rgba(167, 139, 250, 0.3);
}

/* The inset bar doubles the 2px signal rail without changing layout width. */
.history-row:hover,
.history-row:focus-within {
  background: var(--row-tint);
  box-shadow: inset 2px 0 0 var(--row-rail);
}

/* Timestamps sit muted in the tape and sharpen on the row you are reading. */
.history-row:hover .history-time,
.history-row:focus-within .history-time {
  color: var(--text);
}

.history-subhead {
  margin: 1.25rem 0 0.65rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.history-subhead[hidden] {
  display: none;
}

.history-list-head {
  display: grid;
  grid-template-columns: 13.5rem auto minmax(0, 1fr) auto;
  gap: 0.4rem 0.55rem;
  padding: 0 0.7rem 0.4rem;
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.trades-list .history-row {
  margin-bottom: 0.45rem;
}

.history-pnl {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.history-pnl.pos { color: var(--buy); }

.history-pnl.neg { color: var(--sell); }

.eyebrow {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  color: var(--copper);
}

/* A short copper rule leading the eyebrow — a ticker-tape cue that anchors
   the brand block to the left edge. Pseudo-element, not markup: the i18n
   pass rewrites `textContent` on every `[data-i18n]` node and would strip a
   real child element out of this line. */
.eyebrow::before {
  content: "";
  flex: none;
  width: 1.4rem;
  height: 2px;
  border-radius: 1px;
  background: linear-gradient(90deg, var(--copper), rgba(212, 137, 76, 0));
}

.masthead h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2.1rem, 4vw, 3.1rem);
  line-height: 1;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.tagline {
  margin: 0;
  max-width: 34rem;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.5;
  text-wrap: pretty;
}

/* Floating Dismissable Toast Notification */
.toast {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 10050;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 300px;
  max-width: min(480px, calc(100vw - 2.5rem));
  margin: 0;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md, 0.85rem);
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.25);
  font-family: var(--ui);
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--text);
  box-sizing: border-box;
  pointer-events: auto;
  overflow-wrap: anywhere;
  word-break: break-word;
  opacity: 1;
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1), transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease, border-color 0.2s ease;
}

.toast:hover {
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.55), 0 4px 12px rgba(0, 0, 0, 0.35);
  border-color: color-mix(in srgb, var(--line) 75%, var(--primary, #3b82f6));
}

.toast[hidden] {
  display: none !important;
}

.toast.is-fresh {
  animation: toast-slide-in 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.toast.is-dismissing {
  animation: toast-slide-out 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  pointer-events: none;
}

@keyframes toast-slide-in {
  from {
    opacity: 0;
    transform: translateY(-16px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toast-slide-out {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(-12px) scale(0.96);
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast.is-fresh {
    animation: toast-fade-in 0.15s ease forwards;
  }
  .toast.is-dismissing {
    animation: toast-fade-out 0.15s ease forwards;
  }
  @keyframes toast-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
  }
  @keyframes toast-fade-out {
    from { opacity: 1; }
    to { opacity: 0; }
  }
}

/* Toast Inner Layout */
.toast-indicator {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
}

.toast-indicator .toast-icon {
  width: 1.2rem;
  height: 1.2rem;
  display: block;
}

.toast-content {
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--ui);
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--text);
}

.toast-dismiss {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  min-height: 0 !important;
  min-width: 0 !important;
  margin: 0;
  padding: 0 !important;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transform: none !important;
  line-height: 1;
  box-sizing: border-box;
  transition: color 0.15s ease, background 0.15s ease;
}

.toast-dismiss:hover,
.toast-dismiss:focus-visible {
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
  transform: none !important;
  outline: none;
}

.toast-dismiss svg {
  display: block;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* Toast Varieties */
.toast[data-kind="error"] {
  border-color: color-mix(in srgb, var(--sell) 45%, var(--line));
  background: color-mix(in srgb, var(--sell) 12%, var(--panel));
}

.toast[data-kind="error"] .toast-indicator {
  color: var(--sell);
}

.toast[data-kind="ok"] {
  border-color: color-mix(in srgb, var(--buy) 45%, var(--line));
  background: color-mix(in srgb, var(--buy) 12%, var(--panel));
}

.toast[data-kind="ok"] .toast-indicator {
  color: var(--buy);
}

.toast[data-kind="warn"] {
  border-color: color-mix(in srgb, var(--warn) 45%, var(--line));
  background: color-mix(in srgb, var(--warn) 12%, var(--panel));
}

.toast[data-kind="warn"] .toast-indicator {
  color: var(--warn);
}

.toast[data-kind="info"] {
  border-color: color-mix(in srgb, var(--cyan) 45%, var(--line));
  background: color-mix(in srgb, var(--cyan) 12%, var(--panel));
}

.toast[data-kind="info"] .toast-indicator {
  color: var(--cyan);
}

.toast a {
  color: var(--copper);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.toast .toast-link-btn {
  display: inline-flex;
  align-items: center;
  margin-left: 0.65rem;
  padding: 0.2rem 0.65rem;
  border: 1px solid currentColor;
  border-radius: 999px;
  text-decoration: none;
  line-height: 1.25;
  font-size: 0.8rem;
  font-weight: 600;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.toast .toast-link-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.layout {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 1.25rem;
  align-items: start;
}

.signal-wall {
  min-height: 0;
  padding: 1.25rem 1.35rem 1.35rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(160deg, var(--panel), var(--panel-bg));
  box-shadow: inset 0 1px 0 var(--line-soft);
}

.side-badge {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--surface-soft);
}

.side-badge[data-side="ai"],
.side-badge[data-side="two_way"] {
  color: var(--copper);
  border-color: color-mix(in srgb, var(--copper) 45%, var(--line));
}

.side-badge[data-side="short"] {
  color: var(--sell);
  border-color: color-mix(in srgb, var(--sell) 45%, var(--line));
}

.mode-badge {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.mode-badge.armed {
  color: #1a1008;
  background: var(--copper);
  border-color: var(--copper);
}

/* Copper is "orders will reach the broker"; oxblood is "and it is real money". */
.mode-badge.env-live {
  color: #fff5f5;
  background: #8b1e1e;
  border-color: #c23b3b;
}

.env-banner {
  display: none !important;
}

.eyebrow.is-live {
  color: var(--sell);
}

.eyebrow.is-live::before {
  background: linear-gradient(90deg, #c23b3b, rgba(194, 59, 59, 0));
}

body.is-live-env .masthead h1 {
  text-shadow: 0 0 24px rgba(194, 59, 59, 0.25);
}

.signal {
  margin: 0.55rem 0 0.2rem;
  font-family: var(--display);
  font-size: clamp(2.4rem, 6vw, 3.5rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
  transition: color 0.35s ease, transform 0.35s ease;
  font-variant-numeric: tabular-nums;
}

.signal.buy { color: var(--buy); }

.signal.sell { color: var(--sell); }

.signal.hold { color: var(--hold); }

.price {
  margin: 0;
  font-family: var(--mono);
  font-size: 1.2rem;
  color: var(--copper);
  font-variant-numeric: tabular-nums;
}

.price-meta {
  margin: 0.2rem 0 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  line-height: 1.4;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-top: 1.15rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
}

.metrics span {
  display: block;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.metrics strong {
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.reason {
  margin: 0.85rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  min-height: 1.25em;
  line-height: 1.4;
}

.console {
  display: grid;
  gap: 1rem;
  animation: rise 1s ease both;
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  align-self: start;
  padding-bottom: 0.25rem;
  min-width: 0;
  max-width: 100%;
}

.panel {
  padding: 1.1rem 1.15rem 1.2rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

/* Status pill shared by the desk pages. Lives here rather than in a page
   stylesheet because admin, settings and configuration all label state the
   same way. */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--text) 7%, transparent);
  border: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge.is-emerald {
  background: color-mix(in srgb, var(--buy) 14%, transparent);
  border-color: color-mix(in srgb, var(--buy) 40%, transparent);
  color: var(--buy);
}

.badge.is-amber {
  background: color-mix(in srgb, var(--warn) 14%, transparent);
  border-color: color-mix(in srgb, var(--warn) 40%, transparent);
  color: var(--warn);
}

.badge.is-rose {
  background: color-mix(in srgb, var(--sell) 14%, transparent);
  border-color: color-mix(in srgb, var(--sell) 40%, transparent);
  color: var(--sell);
}

.badge.badge-stocks-only {
  background: color-mix(in srgb, #10b981 16%, transparent) !important;
  color: #34d399 !important;
  border: 1px solid color-mix(in srgb, #10b981 38%, transparent) !important;
  box-shadow: 0 1px 3px rgba(16, 185, 129, 0.12);
}

.badge.badge-stocks-only::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 5px currentColor;
  flex-shrink: 0;
}

.badge.badge-options-only {
  background: color-mix(in srgb, #a855f7 18%, transparent) !important;
  color: #c084fc !important;
  border: 1px solid color-mix(in srgb, #a855f7 42%, transparent) !important;
  box-shadow: 0 1px 3px rgba(168, 85, 247, 0.15);
}

.badge.badge-options-only::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 5px currentColor;
  flex-shrink: 0;
}

.badge.badge-options-on {
  background: color-mix(in srgb, #06b6d4 18%, transparent) !important;
  color: #38bdf8 !important;
  border: 1px solid color-mix(in srgb, #06b6d4 40%, transparent) !important;
  box-shadow: 0 1px 3px rgba(6, 182, 212, 0.15);
}

.badge.badge-options-on::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 5px currentColor;
  flex-shrink: 0;
}

.badge.badge-options-off {
  background: color-mix(in srgb, var(--muted) 12%, transparent) !important;
  color: var(--muted) !important;
  border: 1px solid color-mix(in srgb, var(--muted) 28%, transparent) !important;
}

.badge.badge-options-off::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.6;
  flex-shrink: 0;
}

.is-inst-stocks { color: #34d399 !important; }
.is-inst-options { color: #c084fc !important; }
.is-inst-both { color: #38bdf8 !important; }

/* Order status shared across desk order views and bot trade history */
.ord-status {
  display: inline-block;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: normal;
  text-transform: capitalize;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text);
  white-space: nowrap;
}

.ord-status.is-filled {
  color: var(--text);
  font-weight: 500;
}

.ord-status.is-open {
  color: var(--copper);
  font-weight: 600;
}

.ord-status.is-partial {
  color: var(--warn);
  font-weight: 600;
}

.ord-status.is-canceled,
.ord-status.is-rejected,
.ord-status.is-expired {
  color: var(--muted);
  opacity: 0.75;
}

.bot-order-status-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;

  &.is-center {
    justify-content: center;
  }
}

.bot-order-source-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0.1rem 0.38rem;
  border-radius: 999px;
  vertical-align: middle;

  &.is-auto {
    color: var(--cyan, #38bdf8);
    background: color-mix(in srgb, var(--cyan, #38bdf8) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--cyan, #38bdf8) 28%, transparent);
  }

  &.is-manual {
    color: var(--copper, #d4894c);
    background: color-mix(in srgb, var(--copper, #d4894c) 14%, transparent);
    border: 1px solid color-mix(in srgb, var(--copper, #d4894c) 32%, transparent);
  }
}

/* Modal scroll lock. Previously only manual-order.css defined this, so every
   other page added the class and got no effect. */
body.modal-open {
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.panel h2 {
  margin: 0 0 0.9rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.panel-head h2 {
  margin: 0;
}

.panel-hint {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--copper);
}

.panel-hint[data-state="editing"],
.panel-hint[data-state="saving"] {
  color: var(--muted);
}

.panel-hint[data-state="saved"] {
  color: var(--buy);
}

.panel-hint[data-state="invalid"] {
  color: var(--sell);
}

.panel-hint[data-state="locked"] {
  color: var(--hold);
}

.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;
}

.stats {
  margin: 0;
  display: grid;
  gap: 0.55rem;
}

.stats div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-family: var(--mono);
  font-size: 0.9rem;
}

.stats dt {
  margin: 0;
  color: var(--muted);
}

.stats dd {
  margin: 0;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.form {
  display: grid;
  gap: 0.9rem;
  min-width: 0;
}

.field-group {
  margin: 0;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  background: var(--surface-soft);
}

.field-group legend {
  padding: 0 0.35rem;
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.form label {
  position: relative;
  display: grid;
  gap: 0.35rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.form input[type="text"],
.form input[type="number"],
.form input[type="password"],
.form input[type="date"],
.form input[type="url"],
.form input:not([type]),
.form select,
.form textarea {
  width: 100%;
  min-height: 2.75rem;
  border: 1px solid var(--line);
  background: var(--input-bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.95rem;
  padding: 0.65rem 0.7rem;
  outline: none;
  border-radius: var(--radius-sm);
  touch-action: manipulation;
  &#manual-symbol {
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }
}

.form textarea {
  min-height: 6.5rem;
  resize: vertical;
  line-height: 1.4;
  text-transform: none;
  letter-spacing: 0;
}

#field-symbols {
  min-height: 4.25rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form label.stack {
  grid-column: 1 / -1;
}

.ai-keys {
  margin: 0.85rem 0 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.ai-keys a {
  color: var(--copper);
  font-weight: 600;
}

.ai-meta {
  margin: 1rem 0 0;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--copper);
  line-height: 1.4;
}

.ai-watchlist {
  margin-top: 1.25rem;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 0;
  max-height: min(42rem, 62vh);
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.watch-head,
.watch-row {
  display: grid;
  grid-template-columns:
    minmax(4.5rem, 5.75rem)
    3.1rem
    minmax(2.75rem, 4.25rem)
    minmax(0, 1fr);
  gap: 0.35rem 0.55rem;
  align-items: start;
  padding: 0.48rem 0.6rem;
  font-family: var(--mono);
  font-size: 0.74rem;
}

.watch-head {
  position: sticky;
  top: 0;
  z-index: 1;
  padding-bottom: 0.55rem;
  margin-bottom: 0.1rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel), var(--panel-bg));
  color: var(--muted);
  font-size: 0.64rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.watch-head span:nth-child(3),
.watch-row .watch-meta {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.watch-row {
  position: relative;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  transition: background 0.15s ease;
}

.watch-row:first-of-type {
  border-top: 0;
}

.watch-row:hover {
  background: var(--surface-soft);
}

.watch-row.is-featured {
  background: color-mix(in srgb, var(--copper) 10%, transparent);
}

.watch-row::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 2.5px;
  height: 55%;
  border-radius: 0 2px 2px 0;
  background: transparent;
  pointer-events: none;
}

.watch-row[data-signal="buy"]::before {
  background: var(--buy);
}

.watch-row[data-signal="sell"]::before {
  background: var(--sell);
}

.watch-row[data-signal="hold"]::before {
  background: transparent;
}

.watch-sym {
  display: grid;
  gap: 0.12rem;
  min-width: 0;
}

.watch-sym strong {
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.watch-px {
  color: var(--copper);
  font-size: 0.66rem;
  font-variant-numeric: tabular-nums;
  opacity: 0.9;
}

/* Dimmed until a live mark arrives, so a frozen price never reads as a live one. */
.watch-px:not(.is-live) {
  opacity: 0.55;
}

/* Drift since the signal was taken. */
.watch-px.is-up {
  color: var(--buy);
}

.watch-px.is-down {
  color: var(--sell);
}

.watch-row .sig {
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 1.2;
}

.watch-row .sig.buy { color: var(--buy); }

.watch-row .sig.sell { color: var(--sell); }

.watch-row .sig.hold { color: var(--hold); }

.watch-meta {
  color: var(--muted);
  white-space: nowrap;
}

.watch-note {
  min-width: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  color: var(--muted);
  line-height: 1.35;
  white-space: normal;
}

.form .ai-only[hidden] {
  display: none !important;
}

.key-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
  align-items: center;
}

.danger-text {
  color: var(--sell);
}

.danger-text:hover,
.danger-text:focus-visible {
  color: var(--sell);
}

.form select {
  cursor: pointer;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) calc(50% - 2px), calc(100% - 11px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 1.8rem;
}

.watch-row.is-clickable {
  cursor: pointer;
}



/* ── Module: common/footer-and-options.css ─────────────────────────────────────── */

/**
 * Common Desk Footer and Option Contract Details
 * AlgoPaca Modular Stylesheet
 */

/* ==========================================================================
   Desk Footer Component
   ========================================================================== */

.desk-footer {
  margin-top: 4rem;
  padding: 2.25rem 0.5rem 1.75rem;
  background: transparent;
  border: none;
  border-top: 1px solid var(--line-soft);
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: relative;
  z-index: 10;
  animation: rise 0.7s ease both;
}

.desk-footer::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(63, 191, 143, 0.3) 25%,
    rgba(212, 137, 76, 0.35) 50%,
    rgba(63, 191, 143, 0.3) 75%,
    transparent 100%
  );
  pointer-events: none;
}

.desk-footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem 2.5rem;
  flex-wrap: wrap;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--line-soft);
}

.desk-footer-brand-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-width: 14rem;
}

.desk-footer-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.desk-footer-logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  flex-shrink: 0;
  overflow: hidden;
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.desk-footer-brand:hover .desk-footer-logo-icon {
  transform: scale(1.06);
}

.desk-footer-mark-img {
  width: 34px;
  height: 34px;
  display: block;
}

.desk-footer-brand-meta {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.desk-footer-logo {
  font-family: var(--display);
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.1;
  background: linear-gradient(135deg, var(--text) 40%, var(--muted) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.desk-footer-tagline {
  font-family: var(--mono);
  font-size: 0.64rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1.2;
}

.desk-footer-status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.26rem 0.68rem;
  border-radius: 999px;
  background: rgba(63, 191, 143, 0.06);
  border: 1px solid rgba(63, 191, 143, 0.18);
  width: fit-content;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.desk-footer-status:hover {
  background: rgba(63, 191, 143, 0.1);
  border-color: rgba(63, 191, 143, 0.3);
}

.status-beacon-green {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 10px;
  height: 10px;
  flex-shrink: 0;
}

.status-beacon-green .beacon-core {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--buy);
  box-shadow: 0 0 8px var(--buy);
}

.status-beacon-green .beacon-ring {
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 1.5px solid var(--buy);
  opacity: 0.8;
  animation: beacon-pulse 2.2s cubic-bezier(0.24, 0, 0.38, 1) infinite;
}

@keyframes beacon-pulse {
  0% {
    transform: scale(0.6);
    opacity: 0.9;
  }
  70% {
    transform: scale(2.2);
    opacity: 0;
  }
  100% {
    transform: scale(2.2);
    opacity: 0;
  }
}

.desk-footer-status-text {
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--buy);
  white-space: nowrap;
}

.desk-footer-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem 0.65rem;
  justify-content: center;
  flex: 1 1 24rem;
}

.desk-footer-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-decoration: none;
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
  white-space: nowrap;
}

.desk-footer-link:hover {
  color: var(--text);
  background: var(--surface-soft);
  border-color: var(--line-soft);
}

.desk-footer-link.ext-link {
  color: var(--copper);
}

.desk-footer-link.ext-link:hover {
  color: var(--copper);
  background: color-mix(in srgb, var(--copper) 8%, transparent);
  border-color: color-mix(in srgb, var(--copper) 25%, transparent);
}

.desk-footer-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 8rem;
}

.desk-footer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 1.5rem;
  flex-wrap: wrap;
}

.desk-footer-copy {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.85rem 1.25rem;
  flex-wrap: wrap;
  font-size: 0.72rem;
  line-height: 1.45;
}

.desk-footer-copy-symbol {
  font-family: var(--mono);
  font-weight: 500;
  color: #8c9ba8;
  letter-spacing: 0.02em;
}

.desk-footer-disclaimer {
  color: #637282;
  font-size: 0.7rem;
  font-family: var(--mono);
  letter-spacing: 0.01em;
}

@media (max-width: 1024px) {
  .desk-footer-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 1.5rem;
  }
  .desk-footer-links {
    justify-content: flex-start;
    flex: 1 1 100%;
    width: 100%;
  }
  .desk-footer-right {
    justify-content: flex-start;
    width: 100%;
  }
}

@media (max-width: 640px) {
  .desk-footer {
    padding: 1.75rem 0.25rem 1.25rem;
    margin-top: 3rem;
  }
  .desk-footer-links {
    gap: 0.3rem 0.45rem;
  }
  .desk-footer-link {
    font-size: 0.68rem;
    padding: 0.3rem 0.45rem;
  }
  .desk-footer-bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
}

/* Note: Mobile App Shell & Experience styles have been modularized into /static/css/mobile-shell.css for device-specific loading */


/* ══════════════════════════════════════════════════════════════════════
   Mobile-First Layout & Blotter Overrides (<= 860px)
   Wins cascade over all legacy desktop grid definitions above.
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 860px) {
  /* Ensure smooth vertical scrolling while preventing horizontal overflow */
  html {
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    height: auto !important;
    max-width: 100% !important;
  }

  body {
    overflow-x: hidden !important;
    overflow-y: visible !important;
    min-height: 100% !important;
    height: auto !important;
    max-width: 100% !important;
    width: 100% !important;
    position: relative !important;
  }

  .app {
    overflow-x: hidden !important;
    overflow-y: visible !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Single-column page layouts */
  .layout,
  #page-auto-trade.layout {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: 1fr !important;
    width: 100% !important;
    max-width: 100% !important;
    gap: 1.25rem !important;
  }

  #desk-form,
  .panel {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  .history-layout {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: 1fr !important;
    width: 100% !important;
    max-width: 100% !important;
    gap: 1.25rem !important;
  }

  .history-console,
  .fills-panel {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    position: static !important;
    max-height: none !important;
    overflow: visible !important;
  }

  .history-list-head,
  .fills-panel .history-list-head {
    display: none !important;
  }

  .history-row-top,
  .fills-panel .history-row-top {
    grid-template-columns: auto minmax(0, 1fr) auto !important;
  }

  .history-time,
  .fills-panel .history-time {
    grid-column: 1 / -1 !important;
    white-space: normal !important;
  }

  .history-filter-fields,
  .history-custom-range,
  .date-range,
  .pnl-summary {
    grid-template-columns: 1fr !important;
  }

  .range-chips {
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding-bottom: 4px !important;
    scrollbar-width: none !important;
  }

  .range-chips::-webkit-scrollbar {
    display: none !important;
  }

  .range-chips .chip {
    flex-shrink: 0 !important;
    white-space: nowrap !important;
  }

  .manual-layout {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: 1fr !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .bt-layout {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: 1fr !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .page-settings,
  .page-admin {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: 1fr !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Signal Wall Responsive Layout */
  .signal-wall {
    width: 100% !important;
    box-sizing: border-box !important;
    padding: 1.15rem 1rem !important;
  }

  .signal-wall .metrics {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 0.35rem !important;
    text-align: center !important;
    margin-top: 0.85rem !important;
    padding-top: 0.75rem !important;
  }

  .signal-wall .metrics span {
    font-size: 0.62rem !important;
    margin-bottom: 0.2rem !important;
  }

  .signal-wall .metrics strong {
    font-size: 0.95rem !important;
  }

  /* Form & Field Group Responsive Layout */
  .field-group {
    display: grid !important;
    grid-template-columns: 1fr !important;
    width: 100% !important;
    box-sizing: border-box !important;
    padding: 0.75rem 0.85rem !important;
    gap: 0.65rem !important;
  }

  .field-pair-row {
    display: grid !important;
    grid-template-columns: 1fr !important;
    width: 100% !important;
    gap: 0.65rem !important;
  }

  /* Full-width responsive form inputs */
  input, select, textarea {
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  .nice-select {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  .nice-select .list {
    max-width: calc(100vw - 2.5rem) !important;
    left: 0 !important;
    right: 0 !important;
  }

}

/* ── Shared Option Contract Details Modal Component ────────────────── */
.pos-option-details-card,
.modal-content.pos-option-details-card,
.pos-modal-card.pos-option-details-card {
  position: relative;
  z-index: 1;
  max-width: 740px;
  width: min(740px, 95vw);
  max-height: calc(100dvh - 2.5rem);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg, 14px);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  overflow: hidden;

  & .pos-modal-head,
  &.modal-content .modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 1.1rem 1.35rem 0.95rem;
    gap: 0.75rem;
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
  }

  & .bot-option-details-body,
  & .pos-option-details-body {
    flex: 1 1 auto;
    padding: 1.15rem 1.45rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.15rem;
  }

  & .pos-modal-title-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
    flex: 1;
    min-width: 0;
  }

  & .pos-modal-title-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }

  & .pos-modal-title-row h3 {
    margin: 0;
    font-size: 1.12rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text);
  }

  & .pos-opt-badges-group {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
  }

  & .pos-opt-badge-pill,
  & .pos-opt-badge-side,
  & .pos-opt-badge-type,
  & .pos-opt-badge-dte,
  & .badge-moneyness {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.5rem;
    font-family: var(--mono);
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1.2;
    border-radius: 999px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    vertical-align: middle;
  }

  & .pos-opt-badge-pill {
    font-weight: 600;
    color: var(--text);
    background: var(--surface-soft, rgba(255, 255, 255, 0.05));
    border: 1px solid var(--line-soft, rgba(255, 255, 255, 0.1));
  }

  & .pos-opt-badge-side.long,
  & .pos-opt-badge-side.buy,
  & .badge-moneyness.itm {
    background: rgba(16, 185, 129, 0.14);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.35);
  }

  & .pos-opt-badge-side.short,
  & .pos-opt-badge-side.sell,
  & .pos-opt-badge-dte.badge-danger,
  & .badge-moneyness.otm {
    background: rgba(239, 68, 68, 0.14);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.35);
  }

  & .pos-opt-badge-type.call {
    background: rgba(59, 130, 246, 0.14);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.35);
  }

  & .pos-opt-badge-type.put {
    background: rgba(168, 85, 247, 0.14);
    color: #c084fc;
    border: 1px solid rgba(168, 85, 247, 0.35);
  }

  & .pos-opt-badge-dte,
  & .badge-moneyness.atm,
  & .pos-opt-badge-dte.badge-gold {
    background: color-mix(in srgb, var(--copper, #d4894c) 14%, transparent);
    color: var(--copper, #d4894c);
    border: 1px solid color-mix(in srgb, var(--copper, #d4894c) 32%, transparent);
  }

  & .pos-opt-sym-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 0.95rem;
    margin-bottom: 0.85rem;
    background: color-mix(in srgb, var(--ink) 45%, var(--panel));
    border: 1px solid var(--line);
    border-radius: var(--radius-sm, 6px);
  }

  & .pos-opt-sym-info {
    display: flex;
    align-items: center;
    gap: 0.65rem;
  }

  & .pos-opt-sym-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
  }

  & .pos-opt-sym-info strong {
    font-size: 0.92rem;
    letter-spacing: 0.03em;
    color: var(--text);
  }

  & .pos-opt-copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.65rem;
    font-size: 0.74rem;
    font-weight: 600;
    background: color-mix(in srgb, var(--copper, #d4894c) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--copper, #d4894c) 30%, transparent);
    border-radius: var(--radius-xs, 4px);
    color: var(--copper, #d4894c);
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;

    &:hover {
      background: color-mix(in srgb, var(--copper, #d4894c) 22%, transparent);
      border-color: var(--copper, #d4894c);
      transform: translateY(-1px);
    }
  }

  & .pos-opt-rail {
    display: grid;
    grid-template-columns: minmax(115px, 1.15fr) minmax(95px, 0.95fr) minmax(95px, 0.95fr) minmax(105px, 1fr) minmax(130px, 1.35fr);
    gap: 0.5rem;
    padding: 0.65rem;
    margin-bottom: 0.85rem;
    background: color-mix(in srgb, var(--ink) 55%, var(--panel));
    border: 1px solid var(--line);
    border-radius: var(--radius-md, 8px);

    @media (max-width: 640px) {
      grid-template-columns: repeat(2, 1fr);
    }
  }

  & .pos-metric-cell {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.2rem;
    padding: 0.5rem 0.6rem;
    background: color-mix(in srgb, var(--ink) 30%, transparent);
    border: 1px solid color-mix(in srgb, var(--line) 40%, transparent);
    border-radius: var(--radius-xs, 4px);
    min-width: 0;
  }

  & .pos-metric-label {
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  & .pos-metric-val {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.25;

    &.pos { color: var(--buy, #34d399); }
    &.neg { color: var(--sell, #f87171); }
  }

  & .pos-metric-cell-pnl .pos-metric-val {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.2rem;
    white-space: normal;
  }

  & .pos-metric-sub {
    font-size: 0.72rem;
    font-weight: 600;
    opacity: 0.85;
    white-space: nowrap;
  }

  & .pos-opt-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem;

    @media (max-width: 640px) {
      grid-template-columns: 1fr;
    }
  }

  & .pos-opt-section-card {
    background: color-mix(in srgb, var(--ink) 40%, var(--panel));
    border: 1px solid var(--line);
    border-radius: var(--radius-sm, 6px);
    padding: 0.85rem 1rem;
  }

  & .pos-opt-card-title {
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin: 0 0 0.65rem 0;
    padding-bottom: 0.45rem;
    border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
  }

  & .pos-modal-meta-grid {
    display: flex !important;
    flex-direction: column !important;
    gap: 0 !important;
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    border-radius: 0 !important;
  }

  & .pos-modal-meta-item {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
    gap: 0.5rem !important;
    font-size: 0.82rem !important;
    padding: 0.45rem 0 !important;
    border-bottom: 1px solid color-mix(in srgb, var(--line) 35%, transparent) !important;

    &:last-child {
      border-bottom: none !important;
      padding-bottom: 0 !important;
    }

    & span {
      color: var(--muted) !important;
      font-size: 0.82rem !important;
      font-weight: 500 !important;
      text-transform: none !important;
      letter-spacing: normal !important;
    }

    & strong {
      color: var(--text) !important;
      font-size: 0.84rem !important;
      font-weight: 600 !important;
      font-family: var(--mono) !important;
      text-align: right !important;
      letter-spacing: normal !important;
    }
  }

  & .pos-opt-quote-note {
    font-size: 0.7rem;
    margin-top: 0.45rem;

    &:empty {
      display: none !important;
    }
  }

  & .pos-opt-modal-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.95rem 1.45rem;
    border-top: 1px solid var(--line);
    background: var(--surface-soft, color-mix(in srgb, var(--ink) 35%, var(--panel)));
    flex-shrink: 0;
  }

  & .pos-opt-modal-actions {
    display: flex;
    gap: 0.5rem;

    & button.danger,
    & #btn-opt-close-pos {
      background: color-mix(in srgb, var(--sell, #ef4444) 18%, transparent) !important;
      border: 1px solid color-mix(in srgb, var(--sell, #ef4444) 45%, transparent) !important;
      color: var(--sell, #f87171) !important;

      &:hover:not(:disabled) {
        background: var(--sell, #ef4444) !important;
        border-color: var(--sell, #ef4444) !important;
        color: #fff !important;
        transform: translateY(-1px);
      }
    }
  }

  & .pos-opt-action-link {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.85rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    background: var(--surface-soft, rgba(255, 255, 255, 0.05));
    border: 1px solid var(--line, rgba(255, 255, 255, 0.12));
    border-radius: var(--radius-sm, 6px);
    text-decoration: none;
    transition: all 0.15s ease;

    &:hover {
      background: color-mix(in srgb, var(--copper, #d4894c) 14%, transparent);
      border-color: var(--copper, #d4894c);
      color: var(--copper, #d4894c);
    }

    & svg {
      opacity: 0.8;
      transition: transform 0.15s ease;
    }

    &:hover svg {
      opacity: 1;
      transform: translate(1px, -1px);
    }
  }
}
