/* ANALITIC — Dark pastel luxury + gold accents */
:root {
  --bg-deep: #12141c;
  --bg-card: #1a1d28;
  --bg-elevated: #222633;
  --bg-input: #161922;
  --pastel-mauve: #3d3550;
  --pastel-sage: #2a3d38;
  --pastel-dust: #2c2a3a;
  --gold: #c9a962;
  --gold-light: #e8d5a3;
  --gold-dim: #8a7340;
  --text: #e8e6f0;
  --muted: #9a96a8;
  --border: rgba(201, 169, 98, 0.18);
  --border-soft: rgba(255, 255, 255, 0.06);
  --success: #6eb88a;
  --error: #d48484;
  --warning: #d4b06e;
  --radius: 14px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg-deep);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(61, 53, 80, 0.45), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(42, 61, 56, 0.25), transparent);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
}

a {
  color: var(--gold-light);
  text-decoration: none;
}
a:hover {
  color: var(--gold);
  text-decoration: underline;
}

.gold-text {
  color: var(--gold);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.muted {
  color: var(--muted);
}
.small {
  font-size: 0.85rem;
}

/* Auth pages */
body.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: linear-gradient(145deg, var(--bg-card), var(--bg-elevated));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.25rem 2rem;
  box-shadow: var(--shadow);
  text-align: center;
}

.auth-card h1 {
  margin: 0 0 0.35rem;
  font-size: 1.75rem;
}

.auth-card form {
  text-align: left;
  margin-top: 1.5rem;
}

/* App shell */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg-deep) 100%);
  border-right: 1px solid var(--border-soft);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.12em;
  padding: 0 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 1rem;
}

.sidebar nav a {
  display: block;
  padding: 0.65rem 0.85rem;
  margin: 0.2rem 0;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
  transition: background 0.2s, color 0.2s;
}

.sidebar nav a:hover,
.sidebar nav a.active {
  background: rgba(201, 169, 98, 0.12);
  color: var(--gold-light);
  text-decoration: none;
}

.sidebar nav a.active {
  border-left: 3px solid var(--gold);
  padding-left: calc(0.85rem - 3px);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border-soft);
  font-size: 0.85rem;
  color: var(--muted);
}

.main-content {
  flex: 1;
  padding: 1.75rem 2rem 3rem;
  max-width: 1100px;
}

.page-header {
  margin-bottom: 1.75rem;
}

.page-header h1 {
  margin: 0 0 0.35rem;
  font-size: 1.65rem;
  font-weight: 600;
}

.page-header p {
  margin: 0;
  color: var(--muted);
}

/* Cards & forms */
.card {
  background: linear-gradient(160deg, var(--bg-card) 0%, rgba(34, 38, 51, 0.9) 100%);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}

.card h2 {
  margin: 0 0 1rem;
  font-size: 1.1rem;
  color: var(--gold-light);
  font-weight: 600;
}

label {
  display: block;
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  margin-bottom: 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  color: var(--text);
  font-size: 0.95rem;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--gold-dim);
  box-shadow: 0 0 0 3px rgba(201, 169, 98, 0.15);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 768px) {
  .app-shell {
    flex-direction: column;
    padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
  }
  .sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    width: 100%;
    border-right: none;
    border-top: 1px solid var(--border-soft);
    border-bottom: none;
    padding: 0.35rem 0.5rem calc(0.35rem + env(safe-area-inset-bottom, 0px));
    background: rgba(26, 29, 40, 0.97);
    backdrop-filter: blur(8px);
  }
  .sidebar-brand,
  .sidebar-footer {
    display: none;
  }
  .sidebar nav {
    display: flex;
    flex-direction: row;
    justify-content: space-around;
    gap: 0.15rem;
    overflow-x: auto;
  }
  .sidebar nav a {
    flex: 1;
    min-width: 0;
    text-align: center;
    padding: 0.5rem 0.35rem;
    font-size: 0.68rem;
    border-radius: 8px;
    white-space: nowrap;
  }
  .grid-2 {
    grid-template-columns: 1fr;
  }
  .main-content {
    padding: 1rem 1rem 1.25rem;
  }
  .execution-plan-text {
    font-size: 0.9rem;
  }
}

/* Standalone PWA / WebView app */
@media (display-mode: standalone) {
  body {
    padding-top: env(safe-area-inset-top, 0px);
  }
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.7rem 1.35rem;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn:hover {
  transform: translateY(-1px);
  text-decoration: none;
}

.btn-gold {
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dim) 100%);
  color: #1a1510;
  box-shadow: 0 4px 16px rgba(201, 169, 98, 0.35);
}

.btn-gold:hover {
  color: #1a1510;
  box-shadow: 0 6px 22px rgba(201, 169, 98, 0.45);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--gold-light);
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Strategy chips */
.strategy-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.strategy-chip {
  position: relative;
}

.strategy-chip input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.strategy-chip label {
  display: inline-block;
  padding: 0.45rem 0.9rem;
  margin: 0;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: var(--bg-input);
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.strategy-chip input:checked + label,
.strategy-chip label:has(+ input:checked) {
  border-color: var(--gold);
  background: rgba(201, 169, 98, 0.15);
  color: var(--gold-light);
}

#batch-pair-list .strategy-chip label {
  min-width: 5.5rem;
  text-align: center;
  font-weight: 600;
}

#batch-pair-list .strategy-chip input:checked + label {
  box-shadow: 0 0 0 1px var(--gold);
}

/* Upload zone */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: rgba(26, 29, 40, 0.6);
}

.upload-zone:hover,
.upload-zone.dragover,
.upload-zone.paste-ok {
  border-color: var(--gold);
  background: rgba(201, 169, 98, 0.06);
}

.upload-zone input[type="file"] {
  display: none;
}

.preview-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.preview-item {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border-soft);
}

.preview-item img {
  width: 100%;
  height: 100px;
  object-fit: cover;
  display: block;
}

.preview-item .meta {
  padding: 0.5rem;
  background: var(--bg-elevated);
}

.preview-item .remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}

.paste-hint {
  font-size: 0.85rem;
  color: var(--success);
  min-height: 1.2em;
  margin: 0.5rem 0 0;
}
.paste-hint.error {
  color: var(--error);
}

/* Results */
#results.visible {
  display: block;
}
#results {
  display: none;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}

.stat {
  background: var(--bg-input);
  padding: 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
}

.stat .label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat .value {
  font-size: 1rem;
  color: var(--gold-light);
  font-weight: 600;
  margin-top: 0.25rem;
}

.badge {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-bullish {
  background: rgba(110, 184, 138, 0.2);
  color: var(--success);
}
.badge-bearish {
  background: rgba(212, 132, 132, 0.2);
  color: var(--error);
}
.badge-neutral {
  background: rgba(154, 150, 168, 0.2);
  color: var(--muted);
}

/* Execution plan */
.execution-plan-card {
  border: 2px solid var(--gold);
  background: linear-gradient(145deg, rgba(201, 169, 98, 0.12), rgba(22, 25, 34, 0.95));
}

.execution-plan-card h2 {
  color: var(--gold-light);
}

.execution-plan-text {
  font-size: 1.05rem;
  line-height: 1.65;
  color: var(--text);
  margin: 0.75rem 0 1rem;
  padding: 1rem;
  background: var(--bg-input);
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
}

.execution-plan-text .ep-side {
  color: var(--gold-light);
  font-weight: 700;
}

.accuracy-meter {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.75rem;
}

.accuracy-pct {
  font-size: 2rem;
  font-weight: 700;
  color: var(--gold-light);
  line-height: 1;
}

.accuracy-bar {
  flex: 1;
  height: 8px;
  background: var(--bg-input);
  border-radius: 4px;
  overflow: hidden;
}

.accuracy-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold));
  border-radius: 4px;
  transition: width 0.4s ease;
}

.btn-copy-plan {
  margin-top: 0.5rem;
}

.confluence-list,
.warning-list {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
}

.narrative {
  line-height: 1.7;
  color: var(--text);
}

.fundamental-block {
  margin-top: 0.5rem;
}

.fundamental-block .news-item {
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 0.9rem;
}

.disclaimer {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 1rem 0;
}

/* Alerts */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.alert-error {
  background: rgba(212, 132, 132, 0.15);
  border: 1px solid rgba(212, 132, 132, 0.4);
  color: var(--error);
}
.alert-success {
  background: rgba(110, 184, 138, 0.15);
  border: 1px solid rgba(110, 184, 138, 0.4);
  color: var(--success);
}

.error-box {
  background: rgba(212, 132, 132, 0.12);
  border: 1px solid rgba(212, 132, 132, 0.35);
  color: var(--error);
  padding: 0.85rem;
  border-radius: 10px;
  margin-top: 1rem;
}

/* Loading */
.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(18, 20, 28, 0.88);
  z-index: 1000;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.loading-overlay.visible {
  display: flex;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border-soft);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  margin-bottom: 1rem;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  padding: 0.65rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
}

.data-table th {
  color: var(--gold);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.role-badge {
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background: rgba(201, 169, 98, 0.2);
  color: var(--gold-light);
}

code {
  background: var(--bg-input);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.88em;
}

kbd {
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.8em;
}

/* Chart source mode */
.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.mode-tab {
  cursor: pointer;
  margin: 0;
}

.mode-tab input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.mode-tab-inner {
  display: block;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border-soft);
  background: var(--bg-input);
  transition: border-color 0.2s, background 0.2s;
}

.mode-tab input:checked + .mode-tab-inner,
.mode-tab.active .mode-tab-inner {
  border-color: var(--gold);
  background: rgba(201, 169, 98, 0.1);
  box-shadow: 0 0 0 1px rgba(201, 169, 98, 0.25);
}

.mode-tab input:disabled + .mode-tab-inner {
  opacity: 0.45;
  cursor: not-allowed;
}

.chart-mode-panel[hidden] {
  display: none !important;
}

.mode-tab-inner small {
  display: block;
  color: var(--muted);
  margin-top: 0.25rem;
}

.chart-mode-panel {
  margin-top: 0.5rem;
}

.auto-preview {
  min-height: 1.2em;
  margin-top: 0.5rem;
}

/* API status */
.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.65rem;
  margin: 1rem 0;
}

.status-pill {
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  background: var(--bg-input);
  font-size: 0.85rem;
}

.status-pill strong {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
}

.status-pill span {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.status-pill.ok {
  border-color: rgba(110, 184, 138, 0.45);
  background: rgba(110, 184, 138, 0.1);
}

.status-pill.ok strong {
  color: var(--success);
}

.status-pill.fail {
  border-color: rgba(212, 132, 132, 0.45);
  background: rgba(212, 132, 132, 0.1);
}

.status-pill.fail strong {
  color: var(--error);
}

.preview-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.preview-controls .inline-label {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.select-compact {
  width: auto;
  min-width: 90px;
  margin: 0;
  padding: 0.45rem 0.65rem;
}

.chart-preview-box {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #161922;
  max-width: 100%;
}

.chart-preview-box img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 420px;
  object-fit: contain;
}

.batch-detail-stack {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.batch-signal-block {
  padding: 0;
  overflow: hidden;
}

.batch-signal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: rgba(212, 175, 55, 0.06);
}

.batch-signal-header h2 {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
}

.batch-signal-body .card:first-child {
  margin-top: 0;
  border-top: none;
  border-radius: 0;
}

.batch-signal-body .card {
  border-left: none;
  border-right: none;
  border-radius: 0;
}

.batch-signal-body .card:last-child {
  border-bottom: none;
}

.signal-table td.signal-narrative {
  max-width: 280px;
}

.signal-table td.signal-prices {
  white-space: nowrap;
  font-size: 0.9rem;
}

.accuracy-pct-inline {
  font-weight: 700;
  color: var(--gold-light);
}

.signal-row-muted {
  opacity: 0.65;
}

.signal-compact-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.signal-compact-row {
  display: grid;
  grid-template-columns: 7.5rem 1fr auto;
  gap: 0.75rem 1rem;
  align-items: center;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: var(--bg-input);
}

.signal-compact-pair {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.signal-compact-setup {
  font-size: 0.88rem;
  line-height: 1.45;
}

.signal-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
}

.signal-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
}

.signal-modal-box {
  position: relative;
  z-index: 1;
  margin: 4vh auto;
  width: min(960px, 94vw);
  max-height: 92vh;
  overflow: auto;
  background: var(--bg-card, #1a1a1a);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.15rem 1.25rem;
}

.signal-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.signal-modal-head h2 {
  margin: 0;
  font-size: 1.1rem;
}

.signal-modal-chart img {
  width: 100%;
  height: auto;
  border-radius: 8px;
  margin-top: 0.4rem;
}

@media (max-width: 720px) {
  .signal-compact-row {
    grid-template-columns: 1fr;
  }
}
