:root {
  color-scheme: dark;
  --bg: #071012;
  --panel: #0e181b;
  --panel-2: #111d21;
  --border: #26383d;
  --text: #edf4f7;
  --muted: #9aa9b0;
  --soft: #6f7f86;
  --blue: #2e95ff;
  --cyan: #30d6d1;
  --amber: #f5b51b;
  --green: #2ed47a;
  --red: #ff5b51;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 18% 0%, rgba(46, 149, 255, 0.1), transparent 30%), var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

select {
  color-scheme: dark;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1480px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 14px 0 20px;
}

.topbar,
.setup-panel,
.chart-panel,
.decision-panel,
.metric-panel,
.knowledge-panel,
.journal-panel {
  background: linear-gradient(180deg, rgba(18, 30, 35, 0.98), rgba(10, 19, 22, 0.98));
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto;
  gap: 16px;
  align-items: center;
  min-height: 62px;
  padding: 10px 14px;
  border-radius: 8px;
}

.setup-panel {
  display: grid;
  grid-template-columns: 170px 170px 190px minmax(220px, 1fr) minmax(200px, 0.9fr);
  gap: 10px;
  align-items: stretch;
  margin-top: 12px;
  padding: 10px;
  border-radius: 8px;
}

.setup-field,
.setup-card {
  min-height: 72px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: rgba(6, 14, 17, 0.62);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  min-width: 0;
}

.setup-field span,
.setup-card span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.setup-field select {
  width: 100%;
  color: var(--text);
  font-size: 17px;
  font-weight: 780;
  border-radius: 5px;
  padding: 2px 22px 2px 0;
}

.setup-card {
  position: relative;
}

.setup-card strong {
  color: var(--text);
  font-size: 19px;
  line-height: 1.1;
}

.setup-card small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

#entryBudget {
  color: var(--green);
}

#recommendedPeriod {
  color: var(--cyan);
}

#applyPeriodButton {
  position: absolute;
  right: 10px;
  bottom: 10px;
  border: 1px solid rgba(48, 214, 209, 0.32);
  border-radius: 5px;
  background: rgba(48, 214, 209, 0.08);
  color: var(--cyan);
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 800;
}

.period-card strong {
  padding-right: 74px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 25px;
  font-weight: 800;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border: 2px solid var(--blue);
  border-radius: 50%;
  position: relative;
  box-shadow: inset 0 0 0 6px rgba(46, 149, 255, 0.08);
}

.brand-mark::before,
.brand-mark::after {
  content: "";
  position: absolute;
  background: var(--blue);
}

.brand-mark::before {
  width: 48px;
  height: 2px;
  left: -7px;
  top: 17px;
}

.brand-mark::after {
  width: 2px;
  height: 48px;
  top: -7px;
  left: 17px;
}

.market-select,
.capital-box,
.mode-pill,
.icon-button {
  height: 46px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #0b1518;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
}

.market-select {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: 28px 14px;
  align-items: center;
  column-gap: 10px;
  row-gap: 0;
  height: 54px;
  min-width: 190px;
}

.coin-dot {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #f7931a;
  color: white;
  font-size: 10px;
  font-weight: 900;
}

select,
input {
  background: transparent;
  color: var(--text);
  border: 0;
  outline: 0;
}

select option {
  background: #0b1518;
  color: var(--text);
}

select option:checked {
  background: #12314a;
  color: #ffffff;
}

select option:disabled {
  color: var(--soft);
}

.market-select:focus-within,
.setup-field:focus-within,
.journal-form select:focus {
  border-color: rgba(48, 214, 209, 0.55);
  box-shadow: 0 0 0 3px rgba(48, 214, 209, 0.1);
}

.market-select select {
  grid-column: 2;
  grid-row: 1;
  min-width: 112px;
  font-size: 20px;
  font-weight: 750;
}

#marketHint {
  grid-column: 2;
  grid-row: 2;
  color: var(--soft);
  font-size: 10px;
  line-height: 1;
  white-space: nowrap;
}

.beginner-guide {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  padding: 11px 14px;
  border: 1px solid rgba(48, 214, 209, 0.26);
  border-radius: 8px;
  background: rgba(48, 214, 209, 0.06);
}

.guide-icon {
  display: grid;
  place-items: center;
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  border: 1px solid rgba(48, 214, 209, 0.5);
  border-radius: 50%;
  color: var(--cyan);
  font-weight: 900;
}

.beginner-guide strong {
  color: var(--text);
  font-size: 13px;
}

.beginner-guide p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.execution-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 10px;
  padding: 12px 14px;
  border: 1px solid rgba(245, 181, 27, 0.25);
  border-radius: 8px;
  background: rgba(245, 181, 27, 0.05);
}

.execution-status strong {
  display: block;
  margin-top: 5px;
  color: var(--amber);
  font-size: 16px;
}

.execution-status p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.api-badge {
  flex: 0 0 auto;
  border: 1px solid rgba(245, 181, 27, 0.3);
  border-radius: 5px;
  padding: 7px 9px;
  color: var(--amber);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.api-badge.ready {
  border-color: rgba(46, 212, 122, 0.3);
  color: var(--green);
  background: rgba(46, 212, 122, 0.06);
}

.api-badge.pending {
  background: rgba(245, 181, 27, 0.06);
}

.guide-warning {
  margin-left: auto;
  color: var(--amber);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  white-space: nowrap;
}

.capital-box {
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0;
  min-width: 150px;
}

.capital-box span {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.capital-box input {
  width: 110px;
  font-size: 20px;
  font-weight: 750;
}

.mode-pill {
  color: var(--amber);
  background: rgba(245, 181, 27, 0.12);
  border-color: rgba(245, 181, 27, 0.3);
  font-size: 13px;
  font-weight: 850;
  text-transform: uppercase;
}

.icon-button,
.journal-form button,
.panel-heading button {
  color: var(--text);
  background: #101b1f;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 12px;
  margin-top: 12px;
}

.chart-panel,
.decision-panel,
.metric-panel,
.knowledge-panel,
.journal-panel {
  border-radius: 8px;
  min-width: 0;
}

.chart-panel {
  min-height: 620px;
  overflow: hidden;
}

.chart-toolbar {
  height: 46px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
}

.timeframes {
  display: flex;
  gap: 4px;
}

.tf-button {
  width: 44px;
  height: 30px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.tf-button.active {
  color: var(--blue);
  background: rgba(46, 149, 255, 0.12);
}

.status-row {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font-size: 13px;
}

.live-status {
  border: 1px solid rgba(245, 181, 27, 0.26);
  border-radius: 5px;
  padding: 4px 7px;
  color: var(--amber);
  background: rgba(245, 181, 27, 0.06);
  font-size: 12px;
  font-weight: 800;
}

.live-status.active {
  border-color: rgba(46, 212, 122, 0.3);
  color: var(--green);
  background: rgba(46, 212, 122, 0.07);
}

.live-status.waiting {
  color: var(--amber);
}

.live-status.error {
  border-color: rgba(255, 91, 81, 0.34);
  color: var(--red);
  background: rgba(255, 91, 81, 0.07);
}

.status-dot::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 7px;
  background: var(--amber);
}

.status-dot.connected::before {
  background: var(--green);
}

.status-dot.error::before {
  background: var(--red);
}

.chart-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 14px 0;
}

.chart-header h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.chart-header p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.chart-stats {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  color: var(--cyan);
  font-size: 13px;
}

.chart-stats span {
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 6px 9px;
  background: rgba(255, 255, 255, 0.02);
}

#priceCanvas {
  display: block;
  width: 100%;
  max-width: 100%;
  height: 510px;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

#priceCanvas.dragging {
  cursor: grabbing;
}

.chart-legend {
  min-height: 38px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 8px 12px;
  color: var(--muted);
  font-size: 12px;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 22px;
}

#chartMode {
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 4px 8px;
  color: var(--text);
  font-weight: 800;
}

#chartMode.buy-mode {
  border-color: rgba(46, 212, 122, 0.36);
  color: var(--green);
  background: rgba(46, 212, 122, 0.08);
}

#chartMode.sell-mode {
  border-color: rgba(255, 91, 81, 0.36);
  color: var(--red);
  background: rgba(255, 91, 81, 0.08);
}

#chartMode.wait-mode {
  border-color: rgba(245, 181, 27, 0.36);
  color: var(--amber);
  background: rgba(245, 181, 27, 0.08);
}

.legend-dot {
  width: 18px;
  height: 3px;
  border-radius: 99px;
}

.legend-dot.ema20 {
  background: var(--blue);
}

.legend-dot.ema50 {
  background: var(--amber);
}

.legend-dot.ema200 {
  background: var(--cyan);
}

.chart-controls {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.chart-controls button {
  height: 26px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #0b1518;
  color: var(--text);
  padding: 0 9px;
  font-size: 12px;
  font-weight: 850;
}

.chart-controls button:hover,
.chart-controls button:focus-visible {
  border-color: rgba(48, 214, 209, 0.5);
  color: var(--cyan);
  outline: 0;
}

.decision-panel {
  padding: 0 12px 12px;
}

.panel-heading {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.panel-heading button {
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 7px 10px;
  color: var(--muted);
}

.signal-block {
  min-height: 150px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.small-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

#signalText {
  display: block;
  margin-top: 8px;
  color: #c6d0d6;
  font-size: 36px;
  line-height: 1;
  text-transform: uppercase;
}

#signalText.buy {
  color: var(--green);
}

#signalText.sell {
  color: var(--red);
}

.technical-bias {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.confidence-ring {
  width: 116px;
  height: 116px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--amber) 0deg, rgba(255, 255, 255, 0.11) 0deg);
  position: relative;
}

.confidence-ring::after {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  background: var(--panel);
}

.confidence-ring span {
  position: relative;
  z-index: 1;
  font-size: 40px;
  font-weight: 850;
}

.levels,
.risk-box {
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
  margin-top: 12px;
}

.levels div,
.risk-box div,
.risk-box label {
  min-height: 43px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(38, 56, 61, 0.72);
  color: var(--muted);
  font-size: 13px;
}

.levels div:last-child,
.risk-box div:last-child {
  border-bottom: 0;
}

.levels strong,
.risk-box strong {
  color: var(--text);
  font-size: 16px;
}

.danger {
  color: var(--red) !important;
}

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

.risk-box input {
  width: 58px;
  text-align: right;
  color: var(--amber);
  font-weight: 800;
}

.decision-note {
  margin: 12px 0 0;
  padding: 12px;
  border-radius: 7px;
  background: rgba(46, 149, 255, 0.1);
  color: #c8d8e0;
  font-size: 13px;
  line-height: 1.45;
}

.safety-gate {
  display: grid;
  gap: 3px;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(245, 181, 27, 0.28);
  border-radius: 7px;
  background: rgba(245, 181, 27, 0.07);
}

.safety-gate strong {
  color: var(--amber);
  font-size: 12px;
  text-transform: uppercase;
}

.safety-gate span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.safety-gate.open {
  border-color: rgba(46, 212, 122, 0.28);
  background: rgba(46, 212, 122, 0.06);
}

.safety-gate.open strong {
  color: var(--green);
}

.safety-gate.blocked {
  border-color: rgba(255, 91, 81, 0.3);
  background: rgba(255, 91, 81, 0.07);
}

.safety-gate.blocked strong {
  color: var(--red);
}

.analysis-grid {
  display: grid;
  grid-template-columns: 1.25fr 1.25fr repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.metric-panel {
  min-height: 146px;
  padding: 14px;
}

.metric-title {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.metric-panel strong {
  display: block;
  margin-top: 18px;
  font-size: 20px;
  text-transform: uppercase;
}

.metric-panel p {
  margin: 12px 0 0;
  color: #c9d3d8;
  font-size: 13px;
  line-height: 1.45;
}

.action-plan {
  border-color: rgba(48, 214, 209, 0.28);
}

.action-plan strong {
  color: var(--cyan);
}

.consensus-panel {
  border-color: rgba(245, 181, 27, 0.28);
}

.consensus-panel strong {
  color: var(--amber);
}

.timeframe-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.timeframe-badges span {
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 5px 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.timeframe-badges strong {
  display: inline;
  margin: 0 5px 0 0;
  color: inherit;
  font-size: 11px;
}

.timeframe-badges .buy {
  color: var(--green);
  border-color: rgba(46, 212, 122, 0.28);
  background: rgba(46, 212, 122, 0.06);
}

.timeframe-badges .sell {
  color: var(--red);
  border-color: rgba(255, 91, 81, 0.28);
  background: rgba(255, 91, 81, 0.06);
}

.timeframe-badges .wait {
  color: var(--amber);
  border-color: rgba(245, 181, 27, 0.28);
  background: rgba(245, 181, 27, 0.06);
}

.disclaimer-line {
  display: block;
  margin-top: 11px;
  color: var(--soft);
  font-size: 11px;
  line-height: 1.3;
}

.lower-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(0, 1.1fr);
  gap: 10px;
  margin-top: 10px;
}

.knowledge-panel,
.journal-panel {
  min-height: 250px;
  padding: 0 14px 14px;
}

#ruleList {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 9px;
}

#ruleList li {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 11px;
  color: #d4dde1;
  font-size: 13px;
  line-height: 1.35;
  background: rgba(255, 255, 255, 0.02);
}

.journal-form {
  display: grid;
  grid-template-columns: 132px 1fr auto;
  gap: 8px;
  padding: 12px 0;
}

.journal-form select,
.journal-form input,
.journal-form button {
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 10px;
}

.journal-form input {
  background: #0b1518;
}

  .journal-form button {
    color: var(--text);
    font-weight: 750;
    white-space: nowrap;
  }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 7px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 650px;
}

th,
td {
  height: 38px;
  padding: 0 10px;
  border-bottom: 1px solid rgba(38, 56, 61, 0.72);
  text-align: left;
  font-size: 13px;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

td {
  color: #d7e0e4;
}

tbody tr:last-child td {
  border-bottom: 0;
}

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

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

  .workspace,
  .lower-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 680px) {
  .app-shell {
    width: min(100vw - 16px, 1480px);
    padding-top: 8px;
  }

  .topbar,
  .setup-panel,
  .analysis-grid,
  .journal-form {
    grid-template-columns: 1fr;
  }

  .market-select {
    min-width: 0;
    width: 100%;
  }

  .brand {
    font-size: 22px;
  }

  .chart-panel {
    min-height: 520px;
  }

  .chart-toolbar {
    height: auto;
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
  }

  .status-row {
    width: 100%;
    gap: 7px;
    flex-wrap: wrap;
    font-size: 12px;
  }

  .live-status {
    font-size: 11px;
    padding: 4px 6px;
  }

  #priceCanvas {
    height: 430px;
  }

  .chart-header {
    flex-direction: column;
    gap: 8px;
  }

  .beginner-guide {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .execution-status {
    align-items: flex-start;
    flex-direction: column;
  }

  .guide-warning {
    width: 100%;
    margin-left: 38px;
    white-space: normal;
  }

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

  #signalText {
    font-size: 31px;
  }
}
