:root {
  color-scheme: dark;
  --bg: #0b0f14;
  --panel: #111821;
  --panel-2: #151f2a;
  --line: #243241;
  --text: #e9eef4;
  --muted: #8fa0b2;
  --accent: #d8b25c;
  --good: #5fc49d;
  --bad: #e16f72;
  --warn: #e7c66a;
  --info: #64a9dd;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 15, 20, 0.96);
  position: sticky;
  top: 0;
  z-index: 10;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(24px, 3vw, 36px);
  letter-spacing: 0;
}

h2 {
  font-size: 16px;
  letter-spacing: 0;
}

.eyebrow {
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

.shell {
  padding: 22px;
}

.market-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
}

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

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.chart-frame {
  height: 590px;
  background: #090d12;
}

.tradingview-widget-container,
#tradingview_xauusd {
  width: 100%;
  height: 100%;
}

.command-panel {
  min-height: 590px;
}

.clock,
.status-pill {
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  white-space: nowrap;
}

.score-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 16px;
  padding: 18px;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.score-card span {
  color: var(--muted);
}

.score-card strong {
  font-size: 30px;
  letter-spacing: 0;
}

.controls,
.trade-form {
  display: grid;
  gap: 12px;
  padding: 16px;
}

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

label {
  color: var(--muted);
  display: grid;
  gap: 6px;
  font-size: 12px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0d131a;
  color: var(--text);
  padding: 10px 11px;
  min-height: 40px;
}

textarea {
  resize: vertical;
}

.wide {
  grid-column: 1 / -1;
}

.primary-button,
.ghost-button,
.icon-button {
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text);
  min-height: 38px;
  cursor: pointer;
}

.primary-button {
  background: var(--accent);
  color: #11100c;
  font-weight: 800;
  padding: 0 14px;
}

.ghost-button,
.icon-button {
  background: var(--panel-2);
  border-color: var(--line);
  padding: 0 12px;
}

.icon-button {
  width: 38px;
  font-weight: 900;
}

.news-list {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.news-item {
  display: grid;
  grid-template-columns: 20px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d131a;
}

.news-item input {
  min-height: 20px;
}

.news-item strong {
  font-size: 13px;
}

.news-item span {
  color: var(--muted);
  font-size: 12px;
}

.macro-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--muted);
  border-radius: 8px;
  background: #0d131a;
}

.macro-topline,
.macro-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.macro-topline strong {
  font-size: 13px;
}

.macro-status {
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  white-space: nowrap;
  text-transform: uppercase;
}

.macro-meta,
.macro-item small,
.macro-item p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.macro-item p {
  color: var(--text);
}

.macro-link {
  color: var(--info);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.status-pendiente {
  border-left-color: var(--warn);
}

.status-en-progreso {
  border-left-color: var(--bad);
}

.status-ejecutado {
  border-left-color: var(--good);
}

.impact-high {
  color: var(--bad);
}

.impact-medium {
  color: var(--warn);
}

.impact-low {
  color: var(--muted);
}

.stats-panel,
.signal-panel {
  grid-column: span 2;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 16px;
}

.stats-grid div {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d131a;
}

.stats-grid span {
  color: var(--muted);
  font-size: 12px;
}

.stats-grid strong {
  font-size: 24px;
}

.trade-list {
  display: grid;
  gap: 8px;
  padding: 0 16px 16px;
  max-height: 250px;
  overflow: auto;
}

.trade-row,
.signal-row {
  display: grid;
  grid-template-columns: 74px 1fr 70px;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d131a;
}

.trade-row small,
.signal-row small {
  color: var(--muted);
}

.trade-row strong.long,
.signal-row strong.long,
.positive {
  color: var(--good);
}

.trade-row strong.short,
.signal-row strong.short,
.negative {
  color: var(--bad);
}

.signal-list {
  display: grid;
  gap: 8px;
  padding: 16px;
  max-height: 300px;
  overflow: auto;
}

.signal-row span {
  color: var(--accent);
  font-weight: 800;
}

.live-state {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.live-state div {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d131a;
}

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

.live-state strong {
  font-size: 13px;
}

.live-state p {
  grid-column: 1 / -1;
  color: var(--accent);
  line-height: 1.4;
}

.bot-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 0 16px 16px;
  border-bottom: 1px solid var(--line);
}

.bot-card {
  display: grid;
  gap: 6px;
  min-height: 96px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d131a;
}

.bot-card span,
.bot-card small {
  color: var(--muted);
  font-size: 11px;
}

.bot-card span {
  text-transform: uppercase;
}

.bot-card strong {
  color: var(--muted);
}

.bot-card.is-active {
  border-color: rgba(95, 196, 157, 0.7);
}

.bot-card.is-active strong {
  color: var(--good);
}

.bot-card.is-warn {
  border-color: rgba(231, 198, 106, 0.7);
}

.bot-card.is-warn strong {
  color: var(--warn);
}

.bot-card.is-risk {
  border-color: rgba(225, 111, 114, 0.7);
}

.bot-card.is-risk strong {
  color: var(--bad);
}

.webhook-status {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.webhook-status span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  padding: 5px 9px;
  font-size: 12px;
}

.webhook-box {
  display: grid;
  gap: 14px;
  padding: 16px;
  color: var(--muted);
  line-height: 1.55;
}

code {
  display: block;
  max-width: 100%;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #090d12;
  color: var(--info);
  white-space: nowrap;
}

@media (max-width: 1100px) {
  .market-grid,
  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .stats-panel {
    grid-column: auto;
  }

  .command-panel {
    min-height: auto;
  }
}

@media (max-width: 720px) {
  .app-header {
    align-items: flex-start;
    padding: 16px;
  }

  .shell {
    padding: 12px;
  }

  .chart-frame {
    height: 460px;
  }

  .trade-form,
  .stats-grid,
  .live-state,
  .bot-grid {
    grid-template-columns: 1fr;
  }

  .primary-button {
    padding: 0 10px;
  }
}
