/* ═══════════════════════════════════════════════════════════════
   CORE INFRASTRUCTURE SHELL STYLES — AGENTS.md §4 & §5 (Binomo Cockpit Edition)
   ═══════════════════════════════════════════════════════════════ */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

*::-webkit-scrollbar {
  display: none;
}

html,
body {
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 16px;
  line-height: var(--line-height-normal);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

html {
  overflow-x: hidden;
}

body {
  overflow-x: clip;
}

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

input[type="number"] {
  -webkit-appearance: none;
  -moz-appearance: textfield;
}

input[type="email"] {
  text-transform: lowercase;
}

input.uppercase {
  text-transform: uppercase;
}

.mono {
  font-family: 'JetBrains Mono', monospace;
}

.hidden {
  display: none !important;
}

.val-pos {
  color: var(--color-success) !important;
}

.val-neg {
  color: var(--color-error) !important;
}

.ambient-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(130px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.18;
}

.ambient-orb-pink {
  width: 420px;
  height: 420px;
  background: #ec4899;
  top: -140px;
  left: -120px;
}

.ambient-orb-violet {
  width: 480px;
  height: 480px;
  background: #8b5cf6;
  bottom: -160px;
  right: -120px;
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1920px;
  margin: 0 auto;
  padding: 10px 12px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px;
  min-height: 56px;
  border-radius: 14px;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--gradient-subtle);
  border: 1px solid rgba(236, 72, 153, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.brand-logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

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

.brand-title {
  font-size: 1.04rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.brand-subtitle {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.version-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: rgba(139, 92, 246, 0.16);
  border: 1px solid rgba(139, 92, 246, 0.35);
  color: #ddd6fe;
}

.header-status-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: var(--radius-full);
  font-size: 0.71rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.bot-switch-pill {
  cursor: pointer;
  font-family: var(--font-family);
  transition: transform var(--transition-fast), filter var(--transition-fast);
}

.bot-switch-pill:hover {
  transform: translateY(-1px);
  filter: brightness(1.12);
}

.header-account-box {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  padding: 4px 12px;
  border-radius: 10px;
  background: rgba(12, 12, 28, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.1);
  line-height: 1.15;
}

.header-account-top-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-reset-demo-btn {
  background: rgba(139, 92, 246, 0.18);
  border: 1px solid rgba(139, 92, 246, 0.42);
  color: #ddd6fe;
  font-family: var(--font-family);
  font-size: 0.62rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  cursor: pointer;
  transition: filter var(--transition-fast), transform var(--transition-fast);
}

.header-reset-demo-btn:hover {
  filter: brightness(1.2);
  transform: translateY(-1px);
}

.header-user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 10px;
  border-radius: 10px;
  background: rgba(14, 14, 30, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.11);
}

.header-user-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.15;
}

.header-user-name {
  font-size: 0.68rem;
  font-weight: 800;
  color: #f8fafc;
  letter-spacing: 0.03em;
  max-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-user-role {
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.header-user-role.is-master {
  color: #f472b6;
}

.header-user-role.is-client {
  color: #a78bfa;
}

.header-user-role.is-live-client {
  color: #34d399;
}

.header-logout-btn {
  background: rgba(244, 63, 94, 0.14);
  border: 1px solid rgba(244, 63, 94, 0.35);
  color: #fda4af;
  font-family: var(--font-family);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 5px 9px;
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.header-logout-btn:hover {
  background: rgba(244, 63, 94, 0.28);
  color: #ffffff;
}

.header-pnl-box {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  padding: 4px 12px;
  border-radius: 10px;
  background: rgba(12, 12, 28, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.12);
  line-height: 1.15;
  cursor: pointer;
  font-family: var(--font-family);
  transition: transform var(--transition-fast), border-color var(--transition-fast),
    background var(--transition-fast);
}

.header-pnl-box:hover {
  transform: translateY(-1px);
  border-color: rgba(236, 72, 153, 0.45);
}

.header-pnl-box.is-pos {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.16), rgba(12, 12, 28, 0.85));
  border-color: rgba(16, 185, 129, 0.42);
}

.header-pnl-box.is-neg {
  background: linear-gradient(135deg, rgba(244, 63, 94, 0.16), rgba(12, 12, 28, 0.85));
  border-color: rgba(244, 63, 94, 0.42);
}

.header-pnl-label {
  font-size: 0.64rem;
  font-weight: 700;
  color: #cbd5e1;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.header-pnl-val {
  font-size: 0.94rem;
  font-weight: 800;
  color: #e2e8f0;
}

.header-pnl-box.is-pos .header-pnl-val {
  color: #34d399;
}

.header-pnl-box.is-neg .header-pnl-val {
  color: #fb7185;
}

.account-mode-label {
  font-size: 0.66rem;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.account-mode-label.is-live {
  color: #f472b6;
}

.account-balance-val {
  font-size: 0.94rem;
  font-weight: 700;
  color: #ffffff;
}

.header-deposit-btn {
  padding: 8px 14px !important;
  font-size: 0.78rem !important;
  border-radius: 10px !important;
  white-space: nowrap;
}

.regime-neutral {
  background: rgba(148, 163, 184, 0.14);
  border: 1px solid rgba(148, 163, 184, 0.32);
  color: #cbd5e1;
}

.mode-paper {
  background: rgba(59, 130, 246, 0.14);
  border: 1px solid rgba(59, 130, 246, 0.38);
  color: #93c5fd;
}

.mode-live {
  background: rgba(236, 72, 153, 0.18);
  border: 1px solid rgba(236, 72, 153, 0.45);
  color: #fbcfe8;
}

.state-idle {
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.38);
  color: #fcd34d;
}

.state-running {
  background: rgba(16, 185, 129, 0.16);
  border: 1px solid rgba(16, 185, 129, 0.48);
  color: #6ee7b7;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

/* ── Left Icon Rail (Desktop) / Compact Bar (Mobile) ── */
.nav-tabs {
  display: flex;
  gap: 6px;
  padding: 6px;
  border-radius: 14px;
  overflow-x: auto;
}

.tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 10px 8px;
  font-family: var(--font-family);
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  min-width: 64px;
}

.tab-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tab-btn-label {
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.tab-btn.active {
  background: var(--gradient-subtle);
  color: #ffffff;
  border-color: rgba(236, 72, 153, 0.42);
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.22);
}

.tab-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.shell-aside {
  display: none;
}

/* ── Desktop Binomo Cockpit Layout (>= 961px) ── */
@media (min-width: 961px) {
  body[data-active-tab='arena'] {
    height: 100vh;
    overflow: hidden;
  }

  .app-shell {
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr);
    grid-template-rows: auto auto 1fr auto;
    grid-template-areas:
      'header header'
      'banner banner'
      'nav pages'
      'footer footer';
    column-gap: 10px;
    row-gap: 10px;
    align-items: stretch;
  }

  .app-shell[data-active-tab='arena'] {
    height: 100vh;
    max-height: 100vh;
    padding: 8px 10px;
    row-gap: 8px;
    grid-template-rows: auto auto minmax(0, 1fr);
    grid-template-areas:
      'header header'
      'banner banner'
      'nav pages';
  }

  .app-shell[data-active-tab='arena'] .app-footer {
    display: none;
  }

  .app-shell[data-active-tab='arena'] #pages-viewport,
  .app-shell[data-active-tab='arena'] #tab-arena {
    height: 100%;
    min-height: 0;
  }

  .app-shell .top-header {
    grid-area: header;
  }

  .app-shell .confirm-banner {
    grid-area: banner;
  }

  .app-shell .nav-tabs {
    grid-area: nav;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    height: fit-content;
  }

  .app-shell[data-active-tab='arena'] .nav-tabs {
    height: 100%;
  }

  .app-shell #pages-viewport {
    grid-area: pages;
    min-width: 0;
  }

  .app-shell .app-footer {
    grid-area: footer;
  }
}

/* ── Overview Tab keeps Radar Aside on wide screens ── */
@media (min-width: 1240px) {
  .app-shell[data-active-tab='overview'] {
    grid-template-columns: 76px minmax(0, 1fr) 440px;
    grid-template-areas:
      'header header header'
      'banner banner banner'
      'nav pages aside'
      'footer footer aside';
    align-items: start;
  }

  .app-shell[data-active-tab='overview'] .shell-aside {
    grid-area: aside;
    display: flex;
    position: sticky;
    top: 12px;
    height: calc(100vh - 24px);
    min-width: 0;
  }
}

/* ── Auth Gate ── */
.auth-gate-wrap {
  min-height: 78vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  grid-column: 1 / -1;
}

.auth-gate-card {
  width: 100%;
  max-width: 440px;
}

.auth-gate-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.auth-gate-logo {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  flex-shrink: 0;
}

.auth-password-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.auth-password-wrap .input-dark {
  width: 100%;
  padding-right: 46px;
}

.auth-eye-btn {
  position: absolute;
  right: 10px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}

.auth-eye-btn:hover {
  color: var(--color-primary);
}

/* ── Inline Confirmation Banner (Zero Native Popups) ── */
.confirm-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  border-left: 4px solid var(--color-warning);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.16), rgba(236, 72, 153, 0.12));
}

.confirm-icon {
  font-size: 1.4rem;
  color: var(--color-warning);
  flex-shrink: 0;
}

.confirm-body {
  flex: 1;
}

.confirm-body h3 {
  font-size: 0.92rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.confirm-body p {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.confirm-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── Shared Panel & Form Primitives ── */
.panel-card {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.panel-title {
  font-size: 1.08rem;
  font-weight: 700;
}

.panel-desc {
  font-size: 0.84rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-md);
  padding: 10px 18px;
  font-family: var(--font-family);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-secondary:hover {
  border-color: var(--color-secondary);
  background: rgba(139, 92, 246, 0.16);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 9px 14px;
  font-family: var(--font-family);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-ghost:hover {
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.25);
}

.full-width {
  width: 100%;
  padding-top: 11px;
  padding-bottom: 11px;
}

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

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-wide {
  grid-column: span 2;
}

.field-full {
  grid-column: 1 / -1;
}

.field-action-align {
  justify-content: flex-end;
}

.field-group label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

select.input-dark {
  appearance: none;
  background-color: #1c1c36;
  color: var(--text-primary);
  cursor: pointer;
}

select.input-dark option {
  background-color: #1a1a2e;
  color: var(--text-primary);
}

.app-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

@media (max-width: 960px) {
  .nav-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .tab-btn {
    flex-direction: row;
    gap: 6px;
    padding: 8px 6px;
  }

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

  .field-wide,
  .field-full {
    grid-column: 1 / -1;
  }
}

@media (max-width: 540px) {
  .app-shell {
    padding: 8px 8px 28px;
  }

  .top-header {
    padding: 10px 12px;
  }

  .header-deposit-btn {
    display: none;
  }

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

  .panel-card {
    padding: 15px;
  }

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

  .field-wide,
  .field-full,
  .field-action-align {
    grid-column: 1 / -1;
  }

  .confirm-banner {
    flex-direction: column;
    align-items: flex-start;
  }
}
