body {
  margin: 0;
  padding: 0;
  background: #0f1117;
  color: #ffffff;
  font-family: Arial, sans-serif;
  height: 100vh;
  overflow: hidden;
}

#app {
  display: grid;
  grid-template-columns: 1fr 280px;
  height: 100vh;
}

#charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  height: 100vh;
  gap: 2px;
  background: #222;
}

.chart-wrapper {
  display: flex;
  flex-direction: column;
  background: #0f1117;
}

.chart-title, .fullscreen-title {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  background: #161a25;
  font-weight: bold;
  font-size: 14px;
  text-align: center;
  border-bottom: 1px solid #222;
  flex-shrink: 0;
}

.title-bell, .title-measure, .title-fullscreen {
  position: absolute;
  cursor: pointer;
  font-size: 20px;
  padding: 4px 10px;
  background: rgba(34,34,34,0.7);
  border-radius: 4px;
}

.title-bell { left: 8px; }
.title-measure { 
  left: 42px; 
  opacity: 0.5; 
  transition: opacity 0.2s; 
}
.title-measure.active { opacity: 1; }
.title-fullscreen { right: 8px; }

.title-text { flex: 1; }

/* --- NUOVO POSIZIONAMENTO PER LA % --- */
.title-pct {
  position: absolute;
  left: 82px;                /* subito a destra del metro */
  font-size: 14px;
  font-weight: bold;
  color: #ffffff;            /* bianco di base */
  opacity: 0.9;
  transition: color 0.2s;
}

.fullscreen-title {
  padding: 10px;
  font-size: 18px;
  background: #161a25;
}

.fullscreen-title .title-bell { left: 10px; }
.fullscreen-title .title-measure { left: 48px; }
.fullscreen-title .title-fullscreen { right: 10px; }
.fullscreen-title .title-pct {
  left: 92px;                /* adattato per il padding maggiore del fullscreen */
}

.chart-container {
  flex: 1;
  position: relative;
}

#pairs {
  border-left: 1px solid #222;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.pairs-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: #161a25;
  font-weight: bold;
  border-bottom: 1px solid #222;
  flex-wrap: wrap;
  gap: 10px;
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-title {
  font-size: 24px;
  font-weight: bold;
  color: #00ff85;
  text-shadow: 0 0 10px #00ff85;
  margin-right: 12px;
}

#exchange-select,
#sort-select {
  background: #1f2433;
  color: white;
  border: none;
  padding: 6px 10px;
  border-radius: 4px;
  font-weight: bold;
}

#settings-btn {
  background: #2a3150;
  border: none;
  color: white;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
}

#pairs-list {
  flex: 1;
  overflow-y: auto;
}

.pair {
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  align-items: center;
}

.pair:hover { background: #1f2433; }
.pair.active { background: #2a3150; font-weight: bold; }

.pair-symbol {
  display: flex;
  align-items: center;
  gap: 8px;
}

.star {
  cursor: pointer;
  font-size: 18px;
}

.star.favorite {
  color: #FFD700;
}

.green { color: #00ff85; }
.red { color: #ff5252; }

.loading {
  padding: 40px;
  text-align: center;
  color: #aaa;
}

.modal {
  display: none;
  position: fixed;
  z-index: 100;
  left: 0; top: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.8);
  align-items: center;
  justify-content: center;
  overflow: auto;
}

.modal-content {
  background: #161a25;
  padding: 20px;
  width: 340px;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 8px;
  border: 1px solid #222;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.close {
  float: right;
  font-size: 28px;
  cursor: pointer;
  color: #aaa;
}

.modal label {
  display: block;
  margin: 12px 0 6px;
}

.modal input[type=number], .modal input[type=text] {
  width: 100%;
  padding: 6px;
  background: #1f2433;
  border: none;
  color: white;
}

.modal button {
  margin-top: 20px;
  padding: 10px 16px;
  background: #2a3150;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

#apply-settings {
  position: sticky;
  bottom: 0;
  left: 0;
  width: 100%;
  margin-top: 20px;
  padding: 12px;
  background: #2a3150;
  font-size: 16px;
}

.chart-title.green { background: #004d26 !important; }
.chart-title.red { background: #4d0000 !important; }
.chart-title.neutral { background: #161a25 !important; }

#toggle-ema.active, #toggle-bb.active {
  background: #00ff85 !important;
  color: black !important;
}