:root {
  --bg: #111111;
  --card: #1c1c1c;
  --box: #242424;
  --border: rgba(255, 255, 255, 0.05);
  --sky: #38bdf8;
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.1);
  --error: #ef4444;
  --error-bg: rgba(239, 68, 68, 0.1);
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --font-sans: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 500px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

/* Search */
.search-wrapper {
  margin-bottom: 2rem;
}

.search-bar {
  background: var(--card);
  border: 1px solid var(--border);
  padding: 0.5rem;
  border-radius: 1rem;
  display: flex;
  align-items: center;
}

.icon-wallet {
  color: var(--text-dim);
  margin: 0 0.8rem;
}

input {
  flex: 1;
  background: transparent;
  border: none;
  color: white;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  outline: none;
}

button[type="submit"] {
  background: var(--sky);
  color: #000;
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

/* Calendar Section */
.calendar-section {
  background: transparent;
  margin-bottom: 2rem;
}

.calendar-title {
  text-align: center;
  font-size: 1.2rem;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
}

.calendar-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.calendar-nav h2 {
  font-size: 1.4rem;
  font-weight: 500;
  color: var(--text-dim);
}

.nav-arrow {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
}

.calendar-grid-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  text-align: center;
  margin-bottom: 8px;
  color: var(--text-dim);
  font-size: 0.75rem;
  font-weight: 900;
}

.calendar-grid-header div {
  background: var(--card);
  padding: 6px 0;
  border-radius: 4px;
}

.calendar-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.day-box {
  background: var(--card);
  border-radius: 8px;
  aspect-ratio: 1/1.1;
  padding: 6px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  border: 1px solid transparent;
}

.day-box.not-current {
  opacity: 0.2;
}

.day-num {
  font-size: 0.65rem;
  font-weight: 500;
  opacity: 0.5;
}

.day-val {
  font-size: 0.8rem;
  font-weight: 500;
  text-align: center;
}

.box-profit { background: var(--success-bg); color: var(--success); }
.box-loss { background: var(--error-bg); color: var(--error); }

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.stat-box {
  background: var(--card);
  padding: 12px 4px;
  border-radius: 10px;
  text-align: center;
}

.stat-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  display: block;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--font-mono);
}

.stat-value.profit { color: var(--success); }
.stat-value.loss { color: var(--error); }

/* Common Modal Bases */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal {
  background: #1c1c1c;
  width: 100%;
  max-width: 450px;
  border-radius: 2rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
}

/* Modal Refined */
.modal-header-ref {
  padding: 1.5rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.modal-header-ref h3 {
  font-size: 1.2rem;
  font-weight: 900;
  margin-bottom: 0.3rem;
  color: #fff;
}

.modal-header-ref p {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.modal-content {
  padding: 1rem;
  max-height: 50vh;
  overflow-y: auto;
  background: #111;
}

.trade-card {
  background: var(--card);
  border-radius: 1rem;
  padding: 1rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
}

.trade-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.8rem;
}

.coin-name {
  font-weight: 900;
  font-size: 1rem;
  color: #fff;
}

.trade-side {
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 900;
}

.side-buy { background: rgba(16, 185, 129, 0.2); color: var(--success); }
.side-sell { background: rgba(239, 68, 68, 0.2); color: var(--error); }

.trade-card-details {
  background: #181818;
  border-radius: 0.6rem;
  padding: 0.8rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}

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

.detail-label {
  font-size: 0.6rem;
  color: var(--text-dim);
  margin-bottom: 2px;
}

.detail-value {
  font-size: 0.75rem;
  font-weight: bold;
  font-family: var(--font-mono);
}

.pnl-badge {
  font-weight: 900;
  font-size: 1rem;
}

.modal-footer {
  padding: 1rem;
  border-top: 1px solid var(--border);
}

#closeModal {
  width: 100%;
  padding: 1rem;
  background: #242424;
  border: 1px solid var(--border);
  color: #fff;
  border-radius: 4rem;
  font-weight: 900;
  cursor: pointer;
  font-size: 1rem;
}

.hidden { display: none !important; }
.text-success { color: var(--success); }
.text-error { color: var(--error); }

.loader {
  width: 14px;
  height: 14px;
  border: 2px solid #000;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
