:root {
  --bg-base: #0b0e14;
  --bg-panel: #151924;
  --bg-panel-hover: #1e222d;
  --text-main: #d1d4dc;
  --text-muted: #8a93a6;
  --accent: #2962ff;
  --bullish: #089981;
  --bearish: #f23645;
  --gold: #f2a900;
  --border: #2a2e39;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
  --nav-h: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
}

body {
  background: var(--bg-base);
  color: var(--text-main);
  font-family: var(--font);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.4;
  padding-top: var(--safe-top);
}

/* Header */
header {
  background: linear-gradient(180deg, #1a1f2e 0%, var(--bg-panel) 100%);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  flex-wrap: wrap;
  padding-left: calc(16px + var(--safe-left));
  padding-right: calc(16px + var(--safe-right));
}

.logo {
  font-size: clamp(.95rem, 3.5vw, 1.2rem);
  font-weight: 800;
  letter-spacing: -.5px;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.logo .gold-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 10px rgba(242, 169, 0, .6);
  animation: pulse 2s infinite;
  flex-shrink: 0;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 10px rgba(242, 169, 0, .6); }
  50% { box-shadow: 0 0 20px rgba(242, 169, 0, .9); }
}

.logo span {
  color: var(--gold);
}

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

.session-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .72rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.session-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #f23645;
  animation: pulse 1.5s infinite;
  flex-shrink: 0;
}

.session-dot.active {
  background: #089981;
}

.pair-selector {
  background: var(--bg-base);
  color: var(--text-main);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 16px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: border-color .2s;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='%238a93a6'><path d='M6 9L1 4h10z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 10px;
  padding-right: 28px;
  min-height: 42px;
  touch-action: manipulation;
}

.pair-selector:hover, .pair-selector:focus {
  border-color: var(--accent);
}

/* Application Layout */
.app {
  display: grid;
  grid-template-columns: 290px 1fr 320px;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.panel {
  background: var(--bg-panel);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.panel-left {
  border-right: 1px solid var(--border);
}

.panel-right {
  border-left: 1px solid var(--border);
}

.panel-header {
  padding: 14px 18px;
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, .2);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.panel-header .badge {
  font-size: .65rem;
  background: var(--accent);
  color: #fff;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}

.panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}

::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #3a3f4d;
  border-radius: 3px;
}

/* News Feed Items */
.header-ext-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: .75rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, .06);
  transition: all .2s;
}

.header-ext-link:hover {
  color: var(--gold);
  background: rgba(242, 169, 0, .18);
}

.news-item {
  display: block;
  text-decoration: none;
  color: var(--text-main);
  padding: 12px 8px;
  margin: 0 -8px;
  border-radius: 6px;
  border-bottom: 1px solid rgba(42, 46, 57, .7);
  animation: fadeIn .45s ease-out;
  transition: background .2s, color .2s;
  cursor: pointer;
}

.news-item:active {
  background: rgba(255, 255, 255, .06);
}

.news-item:hover {
  background: rgba(255, 255, 255, .04);
  color: #ffffff;
}

.news-item:hover .news-title {
  color: var(--gold);
}

.news-item .ext-icon {
  font-size: .72rem;
  color: var(--text-muted);
  margin-left: 4px;
  transition: color .2s, transform .2s;
  display: inline-block;
}

.news-item:hover .ext-icon {
  color: var(--gold);
  transform: translate(2px, -2px);
}

.news-time {
  font-size: .7rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.news-time .category {
  background: rgba(41, 98, 255, .2);
  color: #6b8cff;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: .65rem;
  font-weight: 600;
}

.news-title {
  font-size: .88rem;
  margin-bottom: 8px;
  line-height: 1.45;
  font-weight: 500;
}

.news-tags {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.tag {
  font-size: .68rem;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 700;
}

.tag.bull {
  background: rgba(8, 153, 129, .18);
  color: #0dbfa0;
}

.tag.bear {
  background: rgba(242, 54, 69, .18);
  color: #ff5c6c;
}

.tag.neutral {
  background: rgba(138, 147, 166, .18);
  color: #9aa3b5;
}

/* Center Panel - Chart Section */
.chart-section {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.chart-header {
  padding: 14px 20px 8px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-shrink: 0;
  gap: 12px;
}

.chart-title {
  font-size: 1.05rem;
  font-weight: 700;
}

.chart-subtitle {
  font-size: .72rem;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.3;
}

.price-display {
  text-align: right;
  flex-shrink: 0;
}

.current-price {
  font-size: clamp(1.4rem, 5vw, 2.2rem);
  font-weight: 700;
  letter-spacing: -1px;
  line-height: 1.1;
  font-family: var(--mono);
  transition: color .3s;
}

.price-change {
  font-size: .82rem;
  font-weight: 600;
  font-family: var(--mono);
  margin-top: 2px;
}

.tradingview-container {
  flex: 1;
  min-height: 0;
  background: #0b0e14;
}

/* Prediction Container */
.prediction-container {
  padding: 16px 18px;
  background: var(--bg-base);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.pred-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 10px;
  flex-wrap: wrap;
}

.pred-title {
  font-size: .95rem;
  font-weight: 700;
  line-height: 1.25;
}

.pred-badge {
  padding: 6px 14px;
  border-radius: 6px;
  font-weight: 800;
  font-size: .82rem;
  letter-spacing: .05em;
  transition: all .3s;
  white-space: nowrap;
}

/* Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.metric-box {
  background: var(--bg-panel);
  padding: 11px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  min-width: 0;
}

.metric-label {
  font-size: .65rem;
  color: var(--text-muted);
  margin-bottom: 5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.metric-val {
  font-size: 1.05rem;
  font-weight: 700;
  font-family: var(--mono);
}

.progress-bg {
  height: 4px;
  background: var(--bg-base);
  border-radius: 3px;
  margin-top: 6px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: 3px;
  transition: width .6s cubic-bezier(.22, 1, .36, 1), background-color .3s;
}

/* Levels */
.levels {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  background: var(--bg-panel);
  padding: 12px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-bottom: 10px;
}

.level-item {
  text-align: center;
  min-width: 0;
}

.level-item span {
  display: block;
  font-size: .62rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 3px;
  letter-spacing: .03em;
}

.level-item strong {
  font-size: .92rem;
  font-family: var(--mono);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

/* Trade Plan */
.trade-plan {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}

.trade-plan-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  gap: 10px;
}

.trade-plan-title {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}

.trade-plan-title .tf-tag {
  background: rgba(242, 169, 0, .18);
  color: var(--gold);
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: 6px;
  font-size: .62rem;
  font-weight: 700;
}

.rr-badge {
  font-size: .72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 4px;
  font-family: var(--mono);
  white-space: nowrap;
}

.rr-badge.good {
  background: rgba(8, 153, 129, .2);
  color: #0dbfa0;
  border: 1px solid rgba(8, 153, 129, .4);
}

.rr-badge.warn {
  background: rgba(242, 169, 0, .18);
  color: #f2a900;
  border: 1px solid rgba(242, 169, 0, .4);
}

.rr-badge.bad {
  background: rgba(242, 54, 69, .18);
  color: #ff5c6c;
  border: 1px solid rgba(242, 54, 69, .4);
}

.trade-plan-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.trade-plan-cell {
  text-align: center;
  min-width: 0;
}

.trade-plan-cell span {
  display: block;
  font-size: .62rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 3px;
  letter-spacing: .03em;
}

.trade-plan-cell strong {
  font-size: .92rem;
  font-family: var(--mono);
  display: block;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.trade-plan-cell small {
  display: block;
  font-size: .58rem;
  color: var(--text-muted);
  margin-top: 2px;
  font-style: italic;
  opacity: .75;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Right Panel Elements */
.fund-section {
  margin-bottom: 22px;
}

.fund-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: .88rem;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.fund-header .tf-tag {
  background: rgba(242, 169, 0, .18);
  color: var(--gold);
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: auto;
  font-size: .62rem;
  font-weight: 700;
}

.fund-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: .82rem;
  color: var(--text-muted);
  gap: 12px;
}

.fund-row span:first-child {
  flex: 1;
  min-width: 0;
}

.fund-row span:last-child {
  font-weight: 700;
  color: var(--text-main);
  font-family: var(--mono);
  text-align: right;
  white-space: nowrap;
}

.macro-impact-box {
  background: rgba(255, 255, 255, .04);
  padding: 12px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, .06);
  margin-top: 10px;
}

.hs-signal {
  padding: 10px 12px;
  border-radius: 6px;
  margin-bottom: 8px;
  animation: fadeIn .3s ease-out;
}

.hs-signal.buy {
  background: rgba(8, 153, 129, .10);
  border-left: 3px solid var(--bullish);
}

.hs-signal.sell {
  background: rgba(242, 54, 69, .10);
  border-left: 3px solid var(--bearish);
}

.hs-signal .hs-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.hs-signal .badge {
  font-size: .62rem;
  padding: 2px 8px;
  border-radius: 3px;
  font-weight: 700;
  font-family: var(--font);
  flex-shrink: 0;
}

.hs-signal.buy .badge {
  background: var(--bullish);
  color: #fff;
}

.hs-signal.sell .badge {
  background: var(--bearish);
  color: #fff;
}

.hs-signal .hs-time {
  font-family: var(--mono);
  font-size: .7rem;
  color: var(--text-muted);
  flex: 1;
  min-width: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hs-signal .hs-outcome {
  font-size: .6rem;
  padding: 2px 7px;
  border-radius: 3px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
  flex-shrink: 0;
  white-space: nowrap;
}

.hs-signal .hs-outcome.tp {
  background: rgba(8, 153, 129, .2);
  color: #0dbfa0;
  border: 1px solid rgba(8, 153, 129, .45);
}

.hs-signal .hs-outcome.sl {
  background: rgba(242, 54, 69, .2);
  color: #ff5c6c;
  border: 1px solid rgba(242, 54, 69, .45);
}

.hs-signal .hs-outcome.both {
  background: rgba(242, 169, 0, .15);
  color: #f2a900;
  border: 1px solid rgba(242, 169, 0, .4);
}

.hs-signal .hs-outcome.pending {
  background: rgba(138, 147, 166, .15);
  color: #9aa3b5;
  border: 1px solid rgba(138, 147, 166, .35);
}

.hs-signal .hs-outcome.hq {
  background: rgba(41, 98, 255, .2);
  color: #6b8cff;
  border: 1px solid rgba(41, 98, 255, .45);
}

.hs-signal .hs-outcome.mq {
  background: rgba(138, 147, 166, .15);
  color: #9aa3b5;
  border: 1px solid rgba(138, 147, 166, .35);
}

.hs-signal .hs-outcome.expired {
  background: rgba(90, 90, 90, .2);
  color: #b0b0b0;
  border: 1px solid rgba(90, 90, 90, .5);
}

.hs-signal .hs-levels {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.hs-signal .hs-levels > div {
  min-width: 0;
  text-align: center;
}

.hs-signal .hs-levels span {
  display: block;
  font-size: .6rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 2px;
  letter-spacing: .03em;
}

.hs-signal .hs-levels strong {
  display: block;
  font-family: var(--mono);
  font-weight: 700;
  font-size: .82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hs-signal .hs-levels .entry strong { color: var(--text-main); }
.hs-signal .hs-levels .sl strong    { color: var(--bearish); }
.hs-signal .hs-levels .tp1 strong   { color: var(--bullish); }

.hs-signal .hs-levels-2 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed rgba(138, 147, 166, .2);
}

.hs-signal .hs-levels-2 > div {
  min-width: 0;
  text-align: center;
}

.hs-signal .hs-levels-2 span {
  display: block;
  font-size: .58rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 2px;
  letter-spacing: .03em;
}

.hs-signal .hs-levels-2 strong {
  display: block;
  font-family: var(--mono);
  font-weight: 700;
  font-size: .76rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hs-signal .hs-levels-2 .tp2 strong { color: #6b8cff; }
.hs-signal .hs-levels-2 .tp3 strong { color: #a47aff; }
.hs-signal .hs-levels-2 .rr strong  { color: var(--text-muted); }

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

/* Mobile Nav Bar */
.mobile-nav {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 100;
  background: rgba(21, 25, 36, .96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

.mobile-nav button {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: .7rem;
  font-weight: 600;
  padding: 10px 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-height: 56px;
  transition: color .2s;
  touch-action: manipulation;
  position: relative;
}

.mobile-nav button .icon {
  font-size: 1.35rem;
  line-height: 1;
  transition: transform .2s;
}

.mobile-nav button.active {
  color: var(--gold);
}

.mobile-nav button.active .icon {
  transform: scale(1.1);
}

.mobile-nav button.active::before {
  content: '';
  position: absolute;
  top: 0; left: 20%; right: 20%;
  height: 2px;
  background: var(--gold);
  border-radius: 0 0 3px 3px;
}

/* Media Queries */
@media (min-width: 1500px) {
  .app {
    grid-template-columns: 320px 1fr 360px;
  }
}

@media (max-width: 1100px) {
  .app {
    grid-template-columns: 250px 1fr;
  }
  .panel-right {
    display: none;
  }
}

@media (max-width: 900px) {
  body { font-size: 14px; }
  header { padding: 10px 14px; gap: 10px; }
  .header-right { width: 100%; justify-content: space-between; }
  .pair-selector { flex: 1; min-width: 0; max-width: 200px; }
  .session-indicator { font-size: .68rem; }

  .app { display: block; position: relative; overflow: hidden; }
  .app > .panel {
    display: none;
    height: 100%;
    width: 100%;
    border: none;
    animation: fadeIn .25s ease-out;
  }
  .app > .panel.active { display: flex; flex-direction: column; }

  .panel-center { overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .chart-section { flex: 0 0 auto; height: 42vh; min-height: 280px; }
  .chart-header { padding: 10px 14px 6px; }
  .chart-title { font-size: .95rem; }
  .chart-subtitle { font-size: .68rem; }
  .current-price { font-size: clamp(1.3rem, 6vw, 1.8rem); }
  .price-change { font-size: .76rem; }

  .prediction-container { padding: 14px 14px 20px; }
  .pred-header { margin-bottom: 12px; }
  .pred-title { font-size: .88rem; }
  .pred-badge { font-size: .78rem; padding: 5px 12px; }

  .metrics-grid { gap: 8px; margin-bottom: 10px; }
  .metric-box { padding: 9px 10px; }
  .metric-label { font-size: .6rem; }
  .metric-val { font-size: .95rem; }

  .levels { padding: 10px 8px; gap: 4px; }
  .level-item span { font-size: .58rem; }
  .level-item strong { font-size: .82rem; }

  .trade-plan { padding: 12px; }
  .trade-plan-grid { grid-template-columns: repeat(2, 1fr); gap: 10px 8px; }
  .trade-plan-cell:first-child { grid-column: 1/-1; }
  .trade-plan-cell strong { font-size: .88rem; }

  .panel-left, .panel-right, .panel-center {
    padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 12px);
  }
  .panel-content { padding: 14px; }

  .mobile-nav { display: flex; }
}

@media (max-width: 480px) {
  header { padding: 8px 12px; }
  .logo { font-size: 1rem; }
  .session-indicator { font-size: .65rem; }
  .pair-selector { font-size: 15px; padding: 9px 12px; padding-right: 26px; }
  .chart-section { height: 38vh; min-height: 240px; }

  .metrics-grid { grid-template-columns: 1fr; gap: 6px; }
  .metric-box { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; padding: 8px 12px; }
  .metric-label { margin-bottom: 0; }
  .metric-val { font-size: .95rem; text-align: right; }
  .progress-bg { grid-column: 1/-1; margin-top: 4px; }

  .levels { grid-template-columns: repeat(5, 1fr); padding: 8px 6px; }
  .level-item span { font-size: .55rem; }
  .level-item strong { font-size: .75rem; }

  .trade-plan-grid { grid-template-columns: repeat(2, 1fr); gap: 8px 6px; }
  .trade-plan-cell strong { font-size: .82rem; }
  .trade-plan-cell small { font-size: .55rem; }

  .pred-title { font-size: .82rem; }
  .pred-badge { font-size: .72rem; padding: 4px 10px; }
  .news-title { font-size: .85rem; }
}
