:root {
  --bg-primary: #0b0e14;
  --bg-secondary: #12161f;
  --bg-card: #181d27;
  --bg-card-hover: #1f2533;
  --bg-input: #0f131a;
  --border-color: #262d3d;
  --border-focus: #f0b90b;

  --text-primary: #eaecef;
  --text-secondary: #848e9c;
  --text-muted: #5e6673;

  --binance-yellow: #f0b90b;
  --binance-yellow-hover: #fcd535;
  --binance-yellow-bg: rgba(240, 185, 11, 0.12);

  --color-buy: #0ecb81;
  --color-buy-bg: rgba(14, 203, 129, 0.12);
  --color-buy-hover: #12d78b;

  --color-sell: #f6465d;
  --color-sell-bg: rgba(246, 70, 93, 0.12);
  --color-sell-hover: #ff526a;

  --accent-blue: #1e88e5;
  --accent-purple: #8e24aa;

  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-glow-yellow: 0 0 15px rgba(240, 185, 11, 0.25);
  --shadow-glow-green: 0 0 15px rgba(14, 203, 129, 0.25);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* NAVBAR */
.navbar {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 0.85rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-icon {
  background: var(--binance-yellow);
  color: #000;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.2rem;
  box-shadow: var(--shadow-glow-yellow);
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
}

.brand-tag {
  font-size: 0.7rem;
  color: var(--binance-yellow);
  font-family: var(--font-mono);
  background: var(--binance-yellow-bg);
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
  font-weight: 600;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* CRYPTO SELECTOR IN NAV */
.crypto-selector-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  padding: 4px 8px;
  border-radius: var(--radius-md);
}

.crypto-selector-group label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-weight: 600;
}

.crypto-select {
  background: transparent;
  color: var(--binance-yellow);
  border: none;
  font-weight: 700;
  font-size: 0.95rem;
  font-family: var(--font-mono);
  outline: none;
  cursor: pointer;
}

.crypto-select option {
  background: var(--bg-card);
  color: var(--text-primary);
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  outline: none;
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
}

.btn-primary {
  background: var(--binance-yellow);
  color: #0b0e14;
}

.btn-primary:hover {
  background: var(--binance-yellow-hover);
  box-shadow: var(--shadow-glow-yellow);
  transform: translateY(-1px);
}

.btn-buy {
  background: var(--color-buy);
  color: #051910;
}

.btn-buy:hover {
  background: var(--color-buy-hover);
  box-shadow: var(--shadow-glow-green);
  transform: translateY(-1px);
}

.btn-sell {
  background: var(--color-sell);
  color: #fff;
}

.btn-sell:hover {
  background: var(--color-sell-hover);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  border-color: var(--border-color);
  color: var(--text-secondary);
}

.btn-outline:hover {
  border-color: var(--text-primary);
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

/* MAIN CONTAINER */
.container {
  max-width: 1380px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1rem;
  flex: 1;
}

/* HERO INITIAL BALANCE BANNER */
.initial-banner {
  background: linear-gradient(135deg, rgba(24, 29, 39, 0.95), rgba(18, 22, 31, 0.95));
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--binance-yellow);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
}

.initial-banner-info {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.initial-pill {
  display: flex;
  flex-direction: column;
}

.initial-pill-label {
  font-size: 0.72rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.initial-pill-val {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.05rem;
  color: #fff;
}

/* DASHBOARD STATS GRID */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.2rem;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.stat-card:hover {
  border-color: rgba(240, 185, 11, 0.4);
  transform: translateY(-2px);
}

.stat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.6rem;
}

.stat-title {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-icon {
  font-size: 1.1rem;
  opacity: 0.7;
}

.stat-main {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.stat-value {
  font-size: 1.65rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: #fff;
}

.stat-unit {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.stat-diff {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
}

.diff-positive {
  color: var(--color-buy);
  background: var(--color-buy-bg);
}

.diff-negative {
  color: var(--color-sell);
  background: var(--color-sell-bg);
}

.diff-neutral {
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
}

/* SECTION WORKSPACE: CALCULADORA Y GRAFICO */
.grid-calculator-charts {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 992px) {
  .grid-calculator-charts {
    grid-template-columns: 1fr;
  }
}

.panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

.panel-title-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
}

.panel-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* STRATEGY TABS */
.strategy-tabs {
  display: flex;
  gap: 0.5rem;
  background: var(--bg-input);
  padding: 4px;
  border-radius: var(--radius-sm);
  margin-bottom: 1.2rem;
  border: 1px solid var(--border-color);
}

.strategy-tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.83rem;
  padding: 8px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.strategy-tab-btn.active.tab-sell {
  background: var(--color-sell);
  color: #fff;
  box-shadow: 0 2px 8px rgba(246, 70, 93, 0.35);
}

.strategy-tab-btn.active.tab-buy {
  background: var(--color-buy);
  color: #051910;
  box-shadow: 0 2px 8px rgba(14, 203, 129, 0.35);
}

/* INPUT FORMS */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}

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

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.input-addon-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.form-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.65rem 0.8rem;
  padding-right: 3.5rem;
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-input:focus {
  border-color: var(--binance-yellow);
  box-shadow: 0 0 0 2px rgba(240, 185, 11, 0.2);
}

.input-addon {
  position: absolute;
  right: 0.8rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 700;
  pointer-events: none;
}

/* QUICK PERCENT BUTTONS */
.quick-pct-group {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.35rem;
  flex-wrap: wrap;
}

.btn-pct {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-weight: 600;
  transition: all 0.15s ease;
}

.btn-pct:hover, .btn-pct.active {
  color: var(--binance-yellow);
  border-color: var(--binance-yellow);
  background: var(--binance-yellow-bg);
}

/* PREVIEW BOX DE RESULTADO DE ESTRATEGIA */
.calc-result-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.1rem;
  margin-bottom: 1.2rem;
  position: relative;
}

.calc-result-box.sell-mode {
  border-left: 4px solid var(--color-sell);
}

.calc-result-box.buy-mode {
  border-left: 4px solid var(--color-buy);
}

.result-main-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  align-items: center;
}

.result-item {
  display: flex;
  flex-direction: column;
}

.result-label {
  font-size: 0.72rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-weight: 700;
}

.result-target-price {
  font-size: 1.55rem;
  font-weight: 800;
  font-family: var(--font-mono);
}

.price-sell {
  color: var(--color-sell);
}

.price-buy {
  color: var(--color-buy);
}

.result-sub {
  font-size: 0.8rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  margin-top: 2px;
}

/* COMMISSIONS CHECKBOX */
.fee-toggle-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  cursor: pointer;
}

.fee-toggle-row input {
  accent-color: var(--binance-yellow);
  cursor: pointer;
}

/* TABLA HISTORIAL */
.history-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 2rem;
}

.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
}

.table-filters {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.filter-btn {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.filter-btn.active {
  background: var(--binance-yellow);
  color: #000;
  border-color: var(--binance-yellow);
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.trading-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: left;
}

.trading-table th {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-weight: 600;
  padding: 0.75rem 0.9rem;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border-color);
}

.trading-table td {
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-family: var(--font-mono);
}

.trading-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.badge-operation {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-buy {
  background: var(--color-buy-bg);
  color: var(--color-buy);
  border: 1px solid rgba(14, 203, 129, 0.3);
}

.badge-sell {
  background: var(--color-sell-bg);
  color: var(--color-sell);
  border: 1px solid rgba(246, 70, 93, 0.3);
}

.btn-icon-danger {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  font-size: 0.9rem;
  transition: color 0.15s ease;
}

.btn-icon-danger:hover {
  color: var(--color-sell);
}

/* MODALES */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: 92%;
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
}

.modal-close-btn:hover {
  color: #fff;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
  border-top: 1px solid var(--border-color);
  padding-top: 1rem;
}

/* TOAST NOTIFICACIONES */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 0.75rem 1.1rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  animation: slideIn 0.25s ease forwards;
  min-width: 250px;
}

.toast.toast-success {
  border-left: 4px solid var(--color-buy);
}

.toast.toast-danger {
  border-left: 4px solid var(--color-sell);
}

.toast.toast-warning {
  border-left: 4px solid var(--binance-yellow);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* FOOTER OBLIGATORIO */
.app-footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 1.25rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: auto;
}

.app-footer a {
  color: var(--binance-yellow);
  text-decoration: none;
}

.app-footer a:hover {
  text-decoration: underline;
}

/* EMPTY STATES */
.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  opacity: 0.4;
}

.empty-state-text {
  font-size: 0.9rem;
}

/* Registro v2 */
[hidden] { display: none !important; }
.modal-overlay:not(.active) { visibility: hidden; }
.help-text { font-size: .8rem; line-height: 1.55; color: var(--text-secondary); margin: .55rem 0; }
.pair-help { margin: 0 0 1rem; }
.spaced { margin: 1rem 0; }
.full-width { width: 100%; }
.notice { padding: 1rem; border: 1px solid var(--binance-yellow); border-radius: var(--radius-md); margin-bottom: 1rem; background: var(--binance-yellow-bg); }
.notice-error { border-color: var(--color-sell); background: var(--color-sell-bg); }
.pending-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 1rem; }
.pending-card { padding: 1rem; border: 1px solid var(--border-color); border-radius: var(--radius-md); background: var(--bg-secondary); min-width: 0; }
.pending-card p { margin: .5rem 0; overflow-wrap: anywhere; }
.pending-actions, .chart-controls { display: flex; flex-wrap: wrap; gap: .5rem; }
.backup-actions { display: flex; flex-direction: column; gap: .7rem; }
.danger { color: var(--color-sell); }
.positive { color: var(--color-buy); }
.negative { color: var(--color-sell); }
.balance-chart { width: 100%; margin: auto 0; min-height: 240px; }
.balance-chart svg { width: 100%; height: auto; }
.stat-main { flex-wrap: wrap; }
.stat-value { font-size: clamp(1rem, 2vw, 1.65rem); overflow-wrap: anywhere; }
.form-input { padding-right: .8rem; }
.form-input:disabled { opacity: .7; }
.btn:disabled { cursor: not-allowed; opacity: .45; transform: none; }
.modal-card { max-width: 620px; }
.trading-table td { overflow-wrap: anywhere; max-width: 260px; }
.trading-table .table-note { min-width: 130px; white-space: pre-wrap; }
.trading-table { min-width: 1200px; }
.trading-table td:not(.table-note) { overflow-wrap: normal; }
.trading-table td:nth-child(1), .trading-table td:nth-child(2), .trading-table td:nth-child(4), .trading-table td:nth-child(5), .trading-table td:nth-child(6), .trading-table td:nth-child(7), .badge-operation { white-space: nowrap; }
.btn:focus-visible, button:focus-visible, select:focus-visible { outline: 2px solid var(--binance-yellow); outline-offset: 3px; }
@media (max-width: 700px) {
  .navbar { position: static; flex-direction: column; align-items: flex-start; padding: 1rem; gap: 1rem; }
  .nav-actions { gap: .5rem; }
  .brand-tag { display: block; margin: .25rem 0 0; width: fit-content; }
  .panel-title-bar { flex-wrap: wrap; gap: .7rem; }
  .strategy-tab-btn { font-size: .75rem; }
  .toast-container { left: 1rem; right: 1rem; bottom: 1rem; }
  .toast { min-width: 0; }
  .stat-value { font-size: 1.35rem; }
}
