:root {
  color-scheme: dark;
  --app-bg: #05070d;
  --app-bg-soft: #090d14;
  --card: #121721;
  --card-alt: #0e141f;
  --panel: #0b0f14;
  --panel-2: #0e141b;
  --border: #1b2230;
  --border-soft: #222d3f;
  --border-strong: #141b26;
  --accent: #ffc107;
  --accent-strong: #ffd54f;
  --text-primary: #f9fafc;
  --text-danger: #e74c3c;
  --text-muted: #f9fafc;
  --muted: #f9fafc;
  --good: #2ecc71;
  --bad: #e74c3c;
  --good-strong: #27e19e;
  --bad-strong: #ff6b6b;
  --shadow-strong: 0 20px 60px rgba(0, 0, 0, 0.35);
  --shadow-card: 0 15px 40px rgba(0, 0, 0, 0.25);
  --radius-lg: 24px;
  --radius-md: 18px;
}

.text-white label {
  font-size: 11.7px;  
}

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

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: clamp(0.5rem, 1vw, 1.5rem);
  background: radial-gradient(circle at top, rgba(255, 193, 7, 0.05), transparent 55%) var(--app-bg);
  color: var(--text-primary);
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: rgba(255, 193, 7, 0.35);
  color: #05070d;
}

img,
svg {
  max-width: 100%;
  height: auto;
}

a {
  color: inherit;
}

.app-shell.container-fluid {
  width: 100%;
  max-width: 1440px;
  margin-inline: auto;
  background: var(--app-bg-soft);
  border: 1px solid var(--border-strong);
  border-radius: 32px;
  box-shadow: var(--shadow-strong);
}

@media (max-width: 480px) {
  body {
    padding: 0.25rem;
  }

  .app-shell.container-fluid {
    padding: 0.5rem !important;
    border-radius: 12px;
    max-width: 100%;
  }

  .card,
  .panel {
    padding: 0.75rem;
    margin-bottom: 0.75rem;
  }

  .row.g-3 {
    --bs-gutter-x: 0.5rem;
    --bs-gutter-y: 0.5rem;
  }

  .metric {
    font-size: clamp(1.5rem, 2.5vw, 2rem);
  }

  .kpi {
    font-size: clamp(1rem, 1.8vw, 1.5rem);
  }

  .btn-accent,
  .btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
  }

  .navbar {
    padding: 0.25rem 0.75rem;
  }

  .logo {
    width: 36px;
    height: 36px;
  }

  .brand-subtitle {
    font-size: 0.7rem;
  }
}

@media (max-width: 768px) {
  body {
    padding: 0.5rem;
  }

  .app-shell.container-fluid {
    padding: 1rem !important;
    border-radius: 20px;
  }

  .card,
  .panel {
    padding: 1.1rem;
  }

  .table-wrapper {
    height: auto;
    max-height: 60vh;
  }

  .brand-subtitle {
    display: none;
  }

  .nav-item.dropdown {
    position: relative !important;
  }

  .dropdown-menu {
    position: static !important;
    display: none !important;
  }

  .dropdown-menu.show {
    display: block !important;
  }

  .navbar-nav {
    width: 100%;
    gap: 0.2rem;
  }

  .navbar-nav .nav-link {
    justify-content: flex-start;
    text-align: left;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
    gap: 0.75rem;
  }

  .navbar-nav .nav-link .bi {
    margin-left: 0;
    margin-right: 0.35rem;
  }

  .dropdown-menu,
  .dropdown-menu.show {
    width: 100% !important;
    text-align: right;
    margin-top: 0.25rem;
    padding: 0;
  }

  .dropdown-menu .dropdown-item {
    justify-content: flex-end;
    padding: 0.35rem 0.65rem;
    border-radius: 0;
    margin: 0;
    background: transparent;
    gap: 0.35rem;
  }

  .dropdown-menu .dropdown-item .bi {
    margin-left: 0;
    margin-right: 0.35rem;
  }

  .navbar-nav .nav-link.dropdown-toggle {
    position: relative;
    padding-right: 2.5rem;
  }
}

.navbar-nav .nav-link.dropdown-toggle {
  position: relative;
  padding-right: 2.5rem;
}

.navbar-nav .nav-link.dropdown-toggle::after {
  content: '';
  position: absolute;
  top: 50%;
  right: 0.85rem;
  width: 0;
  height: 0;
  transform: translateY(-50%);
  border-left: 0.2rem solid transparent;
  border-right: 0.2rem solid transparent;
  border-top: 0.2rem solid currentColor;
  transition: transform 0.2s ease;
}

.navbar-nav .show > .nav-link.dropdown-toggle::after {
  transform: translateY(-50%) rotate(180deg);
  border-top-color: transparent;
  border-bottom: 0.2rem solid currentColor;
}


@media (min-width: 769px) and (max-width: 1024px) {
  .app-shell.container-fluid {
    max-width: 1200px;
  }

  .card,
  .panel {
    padding: 1.25rem;
  }

  .metric {
    font-size: clamp(1.6rem, 2.5vw, 2.2rem);
  }

  .kpi {
    font-size: clamp(1.2rem, 2vw, 1.8rem);
  }
}

.page-wrapper,
.panel,
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
  color: var(--text-primary);
}

.panel + .panel {
  margin-top: 1.5rem;
}

.card.h-100,
.panel.h-100 {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 0.75rem;
}

h1,
h2,
h3,
h4,
h5 {
  color: var(--text-primary);
  margin-bottom: 0.75rem;
  font-weight: 600;
}

.subtle,
.sub {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.metric {
  font-size: clamp(1.8rem, 2.8vw, 2.4rem);
  font-weight: 700;
  color: var(--text-primary);
}

.metric .subtle {
  display: block;
  margin-top: 0.35rem;
}

.kpi {
  font-size: clamp(1.35rem, 2.2vw, 2rem);
  font-weight: 700;
  color: var(--text-primary);
}

.pill {
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  border: 1px solid #243044;
}

.val-pos,
.pnlgood {
  color: var(--good-strong) !important;
}

.val-neg,
.pnlbad {
  color: var(--bad-strong) !important;
}

.status-badge {
  font-size: 0.8rem;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  border: 1px solid #2a3954;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-open {
  color: #9fe7a4;
  border-color: #265e2c;
  background: rgba(46, 204, 113, 0.08);
}

.status-closed {
  color: #e3a2a2;
  border-color: #5e2626;
  background: rgba(231, 76, 60, 0.08);
}

.status-burn {
  background-color: var(--accent) !important;
  color: #000 !important;
}

.navbar {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 0.35rem 1rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.nav-link {
  color: #e2e8f0 ;
  font-weight: 500;
  transition: color 0.2s ease, opacity 0.2s ease;
}

.nav-link:hover,
.nav-link:focus,
.nav-link.active {
  color: var(--accent) !important;
}

.navbar-toggler {
  border: 1px solid var(--border);
}

.navbar-toggler-icon {
  filter: invert(1);
}

.brand-subtitle {
  font-size: 0.8rem;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.15rem;
  font-weight: 500;
}

.logo {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2c3e50 0%, #1a2332 100%);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.btn-accent {
  background: var(--accent);
  color: #0d1117;
  border: none;
  font-weight: 600;
  border-radius: 12px;
  transition: filter 0.2s ease, transform 0.2s ease;
}

.btn-accent:hover {
  background: var(--accent-strong);
  color: #0d1117;
  transform: translateY(-1px);
}

.input-dark,
textarea.input-dark,
select.input-dark,
.form-control-custom,
.form-select-custom,
.search-input,
.price-input {
  width: 100%;
  background: var(--card-alt);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  color: #fff;
  padding: 0.85rem 1rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control-custom::placeholder,
.form-select-custom::placeholder,
.input-dark::placeholder {
  color: var(--text-primary);
}

.input-dark:focus,
textarea.input-dark:focus,
select.input-dark:focus,
.form-control-custom:focus,
.form-select-custom:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.15);
  outline: none;
}

.trading-search {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.trading-search-input {
  flex: 1;
  min-width: 0;
}

.trading-search button {
  white-space: nowrap;
}

@media (max-width: 576px) {
  .trading-search {
    flex-direction: column;
    align-items: stretch;
  }

  .trading-search button {
    width: 100%;
  }
}

.form-select-custom {
  width: 50%;
  padding: 0.5rem;
}

.form-control-custom:focus + .input-icon {
  color: var(--accent);
}

.chart-card canvas {
  max-height: 320px;
}

#tokenChart {
  height: auto !important;
}

.table-wrapper {
  height: 46vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
}

.table-responsive {
  background: radial-gradient(circle at top, rgba(255, 255, 255, 0.02), transparent);
  border-radius: 18px;
  padding: 0.25rem;
}

.trading-strategies-panel {
  gap: 1rem;
}

.trading-strategy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
}

.trading-strategy-grid article.strategy-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: var(--card);
}

.trading-auto-logs .card-body {
  padding: 1.25rem;
}

.trading-logs-list {
  min-height: 220px;
  max-height: 55vh;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 1rem;
  background-color: rgba(15, 15, 24, 0.9);
  padding: 1rem;
  font-family: 'JetBrains Mono', Menlo, Consolas, monospace;
  font-size: 0.85rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.share-preview-wrapper {
  width: 100%;
  border-radius: 1rem;
  overflow: hidden;
  background: var(--border);
}

.share-preview-data {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-top: 1.25rem;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: rgba(11, 15, 25, 0.9);
}

.share-preview-data__item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-height: 60px;
}

.share-preview-data__label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.share-preview-data__item strong {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.share-preview-data__item strong.positive {
  color: var(--good-strong);
}

.share-preview-data__item strong.negative {
  color: var(--bad-strong);
}

.table {
  --bs-table-bg: var(--card);
  --bs-table-striped-bg: rgba(255, 255, 255, 0.02);
  --bs-table-hover-bg: rgba(255, 255, 255, 0.03);
  color: white;
}

.table thead th {
  color: var(--text-primary);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.yellow {
  color: var(--accent) !important;
}

th.yellow {
  vertical-align: middle;
  text-align: center;
  padding: 8px 12px;
}

.table tbody td {
  border-top: 1px solid var(--border);
  vertical-align: middle;
  font-size: 0.95rem;
}

.table-hover tbody tr:hover {
  background: #0e1420;
}

.table tbody tr.burn-row {
  background-color: rgba(255, 193, 7, 0.15) !important;
}

.table tbody tr.burn-row td {
  color: var(--accent) !important;
}

.src-badge {
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  border: 1px solid #2a3954;
  border-radius: 999px;
  color: var(--text-primary);
}

.table-mobile {
  width: 100%;
}

@media (max-width: 768px) {
  .table-mobile thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .table-mobile tbody {
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }

  .table-mobile tbody tr {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    background: var(--card-alt);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1rem;
    box-shadow: var(--shadow-card);
  }

  .table-mobile tbody td {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    border: none;
    padding: 0.35rem 0;
    text-align: right;
  }

  .table-mobile tbody td::before {
    content: attr(data-label);
    flex: 0;
    font-size: 0.8rem;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    white-space: nowrap;
  }

  .table-mobile tbody td:last-child {
    padding-bottom: 0;
  }

  .table-mobile tbody td > *:last-child {
    text-align: right;
  }

  .table-mobile tbody td[data-label="Azioni"] {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.35rem;
    max-width: 100%;
    overflow: hidden;
  }
}

/* Enhanced mobile table responsiveness */
@media (max-width: 480px) {
  .table-responsive {
    font-size: 0.85rem;
  }

  .table th,
  .table td {
    padding: 0.5rem 0.25rem;
    vertical-align: middle;
  }

  .table-mobile tbody tr {
    padding: 0.75rem;
    gap: 0.3rem;
  }

  .table-mobile tbody td {
    padding: 0.25rem 0;
  }

  .table-mobile tbody td::before {
    font-size: 0.75rem;
  }
}

/* Apply table-mobile class to all tables on mobile */
@media (max-width: 768px) {
  .table:not(.table-mobile) {
    display: none;
  }

  .table-mobile:not(.table-mobile) {
    display: table;
  }

  /* Force all tables to be mobile-friendly */
  table.table {
    width: 100%;
  }

  table.table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }

  table.table tbody {
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }

  table.table tbody tr {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    background: var(--card-alt);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1rem;
    box-shadow: var(--shadow-card);
  }

  table.table tbody td {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    border: none;
    padding: 0.35rem 0;
    text-align: right;
  }

  table.table tbody td::before {
    content: attr(data-label);
    flex: 0;
    font-size: 0.8rem;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    white-space: nowrap;
  }

  table.table tbody td:last-child {
    padding-bottom: 0;
  }

  table.table tbody td > *:last-child {
    text-align: right;
  }

  table.table tbody td[data-label="Azioni"] {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.35rem;
    max-width: 100%;
    overflow: hidden;
  }
}

.table-responsive {
  min-width: 0;
  overflow-x: auto;
}

.table-responsive table {
  min-width: 100%;
  width: 100%;
}

.metric,
.subtle,
.footer-note,
.search-input,
.price-input {
  color: inherit;
}

.footer-note {
  font-size: 0.85rem;
  color: var(--text-primary);
}

iframe {
  border-radius: 12px;
}

.stat-positive {
  color: #4caf50;
}

.stat-negative {
  color: #f44336;
}

.card-small {
  padding: 0.5rem;
  text-align: center;
  color: var(--text-primary);
}

.card-small h5 {
  margin: 0;
}

.card-small p {
  margin: 0;
  font-size: 0.85rem;
}

.cleanup-btn,
.cleanup-run-btn {
  background: var(--accent) !important;
  color: #0d1117;
  border: none;
  padding: 10px 20px;
  border-radius: 10px;
  cursor: pointer;
  transition: 0.2s;
}

.cleanup-btn:hover,
.cleanup-run-btn:hover {
  background: var(--accent-strong) !important;
}

.cleanup-modal {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.cleanup-modal.hidden {
  display: none;
}

.cleanup-modal-content {
  background: #18181b;
  color: var(--text-primary);
  padding: 30px;
  border-radius: 20px;
  width: 90%;
  max-width: 500px;
  text-align: center;
  box-shadow: 0 0 15px var(--accent) !important;
  position: relative;
}

.cleanup-modal-content h2 {
  margin-bottom: 20px;
}

.cleanup-modal-content .close {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 22px;
  cursor: pointer;
}

.swal2-popup {
  background: #121212 !important;
  color: #eaeaea !important;
  border: 1px solid #2a2a2a;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
}

.swal2-title {
  color: #fff !important;
  font-weight: 600;
}

.swal2-html-container {
  color: #ccc !important;
}

.swal2-confirm {
  background-color: var(--accent) !important;
  color: #000 !important;
  border: none;
}

.swal2-cancel {
  background-color: #6c757d !important;
  color: #fff !important;
  border: none;
}

.swal2-icon.swal2-success {
  border-color: #00c853 !important;
  color: #00c853 !important;
}

.swal2-icon.swal2-error {
  border-color: #ff1744 !important;
  color: #ff1744 !important;
}

.dropdown-menu .dropdown-item {
  color: #f8f9fa;
  transition: all 0.2s ease;
}

.dropdown-menu .dropdown-item:hover,
.dropdown-menu .dropdown-item:focus,
.dropdown-menu .dropdown-item.active-sub {
  background-color: var(--accent) !important;
  color: #000 !important;
  font-weight: 600;
}

.blink {
  animation: flash 1s ease-in-out 1;
}

@keyframes flash {
  0% {
    background: rgba(46, 204, 113, 0.15);
  }
  50% {
    background: rgba(46, 204, 113, 0.05);
  }
  100% {
    background: transparent;
  }
}

.landing-body {
  background: radial-gradient(circle at top, rgba(255, 193, 7, 0.12), transparent 60%) #03040a;
}

.landing-page {
  max-width: 1200px;
  margin: 0 auto;
}

.landing-header {
  border: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.04), rgba(2, 4, 8, 0.8));
  backdrop-filter: blur(12px);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.landing-hero {
  background: linear-gradient(180deg, rgba(12, 17, 27, 0.85), rgba(4, 7, 12, 0.95));
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-card);
}

.landing-stat {
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 0.9rem;
  text-align: center;
  background: rgba(255, 255, 255, 0.02);
}

.landing-stat .stat-value {
  font-size: 1.8rem;
  font-weight: 700;
}

.landing-card {
  border-radius: var(--radius-md);
  padding: 1.5rem;
  background: var(--card);
  border: 1px solid var(--border);
  min-height: 220px;
}

.landing-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--panel);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--accent);
  margin-bottom: 1rem;
}

.screen-caption {
  font-size: 0.9rem;
  color: #9ba7c2;
}

.screen-card {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.25rem;
  background: var(--card-alt);
}

.landing-section h2 {
  font-size: clamp(1.9rem, 2.4vw, 2.3rem);
}

.landing-hero h1 {
  font-size: clamp(2.6rem, 3.4vw, 3.6rem);
}

.screen-icon {
  width: 64px;
  height: 64px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

.text-secondary-panel {
  min-height: 260px;
}

.logo-lg {
  width: clamp(120px, 18vw, 160px);
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 0 20px rgba(255, 193, 7, 0.4));
}

.hero-image {
  max-width: 420px;
  height: auto;
  object-fit: contain;
  margin: 0 auto;
}

.header-actions {
  justify-content: flex-end;
}

@media (max-width: 576px) {
  .header-actions {
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
  }
  .header-actions .btn {
    width: 100%;
  }
}
