/* Estructura y componentes del dashboard — vocabulario visual portado de zafiro,
   adaptado a futuros (señales, decisiones LLM, precios, cuenta). */

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 20px 48px;
}

/* ── Header ─────────────────────────────────────────────────────────────── */

.header {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0 20px;
}

.header h1 {
  font-size: 24px;
  letter-spacing: -0.02em;
}

.header-subtitle {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

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

.pill {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-1);
  color: var(--text-secondary);
  font-size: 13px;
}

.pill-good {
  color: var(--status-good);
}

.pill-warning {
  color: var(--status-warning);
}

.pill-critical {
  color: var(--status-critical);
}

/* ── Layout ─────────────────────────────────────────────────────────────── */

.layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  align-items: start;
  transition: opacity 0.2s;
}

.layout-refreshing {
  opacity: 0.85;
}

.layout-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.layout-side {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.banner {
  margin-bottom: 16px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  font-size: 14px;
}

.banner-warning {
  color: var(--status-warning);
}

.banner-critical {
  color: var(--status-critical);
  margin-bottom: 0;
}

/* ── Cards, badges y chips ──────────────────────────────────────────────── */

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
}

.card h2 {
  font-size: 16px;
  margin-bottom: 12px;
}

.card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.card-header h2 {
  margin-bottom: 12px;
}

.card-count {
  font-size: 12.5px;
  color: var(--text-muted);
}

.badge {
  font-size: 12.5px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  white-space: nowrap;
}

.badge-good {
  color: var(--status-good);
}

.badge-warning {
  color: var(--status-warning);
}

.badge-critical {
  color: var(--status-critical);
}

.badge-muted {
  color: var(--text-muted);
}

.chip {
  font-size: 12px;
  color: var(--text-muted);
  padding: 2px 8px;
  background: var(--page);
  border-radius: 6px;
  white-space: nowrap;
}

.num,
.mono {
  font-variant-numeric: tabular-nums;
}

.pos {
  color: var(--status-good);
}

.neg {
  color: var(--status-critical);
}

.empty-state {
  color: var(--text-muted);
  font-size: 14px;
  margin: 8px 0;
}

.empty-card {
  text-align: center;
  padding: 32px;
}

.btn {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-1);
  cursor: pointer;
  font-size: 14px;
}

.btn:hover {
  border-color: var(--text-muted);
}

.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}

.btn-primary:hover {
  filter: brightness(1.1);
  border-color: transparent;
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: default;
}

.btn-small {
  padding: 4px 10px;
  font-size: 13px;
}

.btn-selected {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}

.btn-ghost {
  border: none;
  background: none;
  padding: 4px 8px;
  font-size: 18px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
}

.btn-ghost:hover {
  color: var(--text-primary);
}

/* ── Señal más reciente ─────────────────────────────────────────────────── */

.signal-hero {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.signal-symbol {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.signal-time {
  margin-left: auto;
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.signal-status {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.signal-levels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.level {
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
}

.level span {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.level strong {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.signal-notes {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 14px;
}

/* ── Tabla de señales ───────────────────────────────────────────────────── */

.signals-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.signals-table th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 500;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.signals-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}

.signals-table tbody tr {
  cursor: pointer;
}

.signals-table tbody tr:hover td {
  color: var(--text-primary);
  background: var(--page);
}

.signals-table .num {
  text-align: right;
}

.signals-table .sym {
  font-weight: 600;
  color: var(--text-primary);
}

.cell-reason {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-scroll {
  overflow-x: auto;
}

/* ── Feed de decisiones ─────────────────────────────────────────────────── */

.feed-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.feed-item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.feed-item:hover .feed-label {
  color: var(--accent);
}

.feed-item:last-child {
  border-bottom: none;
}

.feed-icon {
  font-size: 13px;
  width: 20px;
  text-align: center;
}

.feed-icon-good {
  color: var(--status-good);
}

.feed-icon-critical {
  color: var(--status-critical);
}

.feed-icon-warning {
  color: var(--status-warning);
}

.feed-icon-muted {
  color: var(--text-muted);
}

.feed-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.feed-label {
  font-size: 13.5px;
  font-weight: 600;
}

.feed-sub {
  font-size: 12.5px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.feed-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.feed-time {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.feed-status {
  font-size: 11.5px;
  white-space: nowrap;
}

/* ── Precios ────────────────────────────────────────────────────────────── */

.prices-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 340px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.price-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 5px 2px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.price-row:last-child {
  border-bottom: none;
}

.price-sym {
  font-weight: 600;
  color: var(--text-primary);
}

.price-name {
  color: var(--text-muted);
  font-size: 12px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.price-value {
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

.price-change {
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  width: 64px;
  text-align: right;
}

/* ── Cuenta ─────────────────────────────────────────────────────────────── */

.account-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.positions-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.position-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 2px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.position-row:last-child {
  border-bottom: none;
}

.position-sym {
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

/* ── Gráfica ────────────────────────────────────────────────────────────── */

.price-chart {
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}

.chart-ranges {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.chart-container {
  position: relative;
  width: 100%;
}

.chart-tick {
  fill: var(--text-muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.chart-level-label {
  fill: var(--text-secondary);
  font-size: 11px;
}

.chart-last-label {
  fill: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
}

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  min-width: 130px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  z-index: 5;
}

.tooltip-price {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
}

.tooltip-key {
  display: inline-block;
  width: 12px;
  height: 2px;
  background: var(--series-1);
}

.tooltip-meta {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.chart-legend {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--text-secondary);
  flex-wrap: wrap;
}

.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: baseline;
}

/* ── Drawer de detalle ──────────────────────────────────────────────────── */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 40;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(580px, 100vw);
  background: var(--page);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 20px;
  z-index: 41;
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 20px;
}

.drawer-header h2 {
  font-size: 17px;
  line-height: 1.3;
}

.drawer-sub {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.drawer-section {
  margin-bottom: 24px;
}

.drawer-section h3 {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.detail-table th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 500;
  padding: 5px 8px 5px 0;
  width: 42%;
  vertical-align: top;
}

.detail-table td {
  padding: 5px 0;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.drawer-rationale {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.5;
}

.drawer-list {
  margin: 0;
  padding-left: 18px;
  font-size: 13.5px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.validation-notes {
  color: var(--status-critical);
}

.info-banner {
  margin-top: 10px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--status-critical);
}

/* ── Login ──────────────────────────────────────────────────────────────── */

.login-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: min(380px, 100%);
  text-align: center;
}

.login-card h1 {
  font-size: 22px;
  margin-bottom: 4px;
}

.login-sub {
  color: var(--text-secondary);
  font-size: 14px;
  margin: 0 0 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  margin-bottom: 10px;
}

.field span {
  font-size: 13px;
  color: var(--text-secondary);
}

.field input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--page);
  color: var(--text-primary);
  font: inherit;
}

.login-card .field {
  text-align: left;
}

.login-btn {
  width: 100%;
  margin-top: 4px;
}

.form-message {
  margin: 10px 0 0;
  font-size: 14px;
}

.form-message-error {
  color: var(--status-critical);
}

@media (max-width: 900px) {
  .signal-levels {
    grid-template-columns: 1fr 1fr;
  }
}
