:root {
  --bg: #1c1e26;
  --panel: #262a34;
  --panel-2: #2b2f3b;
  --panel-3: #232731;
  --text: #e7ebf2;
  --muted: #aab1c0;
  --line: #3a3f4d;
  --green: #38d66b;
  --green-soft: rgba(56, 214, 107, 0.18);
  --red: #ff5e73;
  --shadow: 0 16px 38px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(900px 500px at 70% -10%, #2a2f40, transparent 60%),
    radial-gradient(800px 500px at -5% 110%, rgba(56, 214, 107, 0.08), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  padding: 20px;
  letter-spacing: 0.1px;
}

.title {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 4px 0 18px;
}

.subtitle {
  margin: -8px 0 14px;
  text-align: center;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.2px;
}

.brand {
  font-size: 38px;
  font-weight: 900;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, #50ef81, #38d66b 45%, #6cf09d);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 14px rgba(56, 214, 107, 0.24);
}

.month-pnl-banner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent), var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
  margin: 0 auto 14px;
  color: var(--muted);
  font-weight: 700;
  position: relative;
  left: 50%;
  transform: translateX(-50%);
}

#monthPnlHeader {
  color: var(--green);
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.account-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 14px;
}

.account-bar label {
  font-size: 0.86rem;
  font-weight: 800;
  color: var(--muted);
}

.account-bar select {
  min-width: 170px;
  max-width: 260px;
  background: #1f2430;
  color: var(--text);
  border: 1px solid #46506a;
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
  font-weight: 700;
}

.danger-chip {
  border-color: rgba(255, 94, 115, 0.65);
  color: #ffdce2;
}

.danger-chip:hover {
  border-color: #ff6d84;
  background: rgba(255, 94, 115, 0.14);
}

.top-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent), var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.stat-label {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.86rem;
  margin-bottom: 4px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.stat-value {
  color: var(--text);
  font-weight: 900;
  font-size: 1.28rem;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

#profit,
#net {
  color: var(--green);
}

#loss {
  color: #ff7f90;
}

.stat-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: rgba(126, 160, 255, 0.15);
  color: #bdd0ff;
  font-size: 0.75rem;
  line-height: 1;
}

.stat-card-winrate {
  position: relative;
  overflow: hidden;
}

.winrate-meter {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 74px;
  height: 42px;
  opacity: 0.95;
  pointer-events: none;
}

.winrate-svg {
  width: 100%;
  height: 100%;
}

.meter-bg {
  fill: none;
  stroke: rgba(185, 192, 206, 0.22);
  stroke-width: 10;
  stroke-linecap: round;
}

.meter-fill {
  fill: none;
  stroke: var(--green);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 151;
  stroke-dashoffset: 151;
  transition: stroke-dashoffset 320ms ease, stroke 220ms ease;
}

.layout {
  display: flex;
  gap: 14px;
}

.left {
  width: 59%;
}

.right {
  width: 41%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px;
  margin-bottom: 12px;
}

.calendar-header h3 {
  margin: 0;
  font-size: 1.05rem;
  color: var(--text);
  letter-spacing: -0.01em;
}

.goalBox {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent), var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  margin-bottom: 12px;
  text-align: center;
  padding: 14px;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.goalBox:hover {
  transform: translateY(-2px);
  border-color: #4a5163;
}

#goalValue {
  font-size: 1.45rem;
  font-weight: 900;
  color: var(--green);
  margin-top: 4px;
}

#goalProgress {
  color: var(--muted);
  font-weight: 700;
}

.weekdays {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 0;
}

.weekdays div {
  text-align: center;
  color: #cfd5e2;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 8px 4px;
}

#calendar {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: var(--panel-3);
}

#calendar.calendar-anim {
  animation: monthSlideIn 220ms ease;
}

#calendar.calendar-prev {
  animation-name: monthSlideInPrev;
}

#calendar > div {
  min-height: 96px;
}

.day {
  padding: 14px 8px;
  background: #232733;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: center;
  cursor: pointer;
  color: #cfd4e1;
  transition: background 0.18s ease, transform 0.18s ease;
}

.day:hover {
  background: #2b3040;
}

.day strong {
  display: block;
  font-size: 1rem;
  margin-bottom: 3px;
}

.day.today {
  box-shadow: inset 0 0 0 2px #74a5ff;
  background: linear-gradient(180deg, rgba(116, 165, 255, 0.18), rgba(116, 165, 255, 0.08));
}

.green {
  background: var(--green-soft);
  color: var(--green);
  font-weight: 800;
}

.red {
  background: rgba(255, 94, 115, 0.14);
  color: var(--red);
  font-weight: 800;
}

.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent), var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 14px 10px;
  height: 286px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 220ms ease;
}

.card:hover {
  transform: translateY(-2px);
  border-color: #4f5670;
  box-shadow: 0 20px 46px rgba(0, 0, 0, 0.42);
}

#drawdown,
#avgStats {
  margin: 0 0 10px;
  font-size: 1.05rem;
  color: #dfe5f1;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.card-head h3 {
  margin: 0;
}

.range-toggle {
  display: inline-flex;
  gap: 6px;
  background: #1f2430;
  border: 1px solid #3f4658;
  border-radius: 999px;
  padding: 4px;
}

.range-btn {
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.8rem;
  font-weight: 800;
  border: 1px solid transparent;
  background: transparent;
  color: #b9c0ce;
}

.range-btn:hover {
  background: #2f3748;
  border-color: #53617d;
}

.range-btn.active {
  background: #38d66b;
  color: #132018;
  border-color: #54e583;
}

.card canvas {
  flex: 1;
  max-height: 220px;
}

button {
  background: #2f3441;
  border: 1px solid #4a5163;
  color: var(--text);
  padding: 9px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: #66708a;
  background: #373d4b;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 18, 0.7);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1001;
}

.modalContent {
  background: #262a34;
  border: 1px solid var(--line);
  border-radius: 14px;
  width: min(460px, 96vw);
  padding: 16px;
  box-shadow: var(--shadow);
  max-height: 86vh;
  overflow: auto;
}

.modalContent h3 {
  margin: 0 0 10px;
}

input,
textarea {
  width: 100%;
  margin: 6px 0;
  padding: 10px 11px;
  border-radius: 10px;
  border: 1px solid #46506a;
  background: #1e222d;
  color: var(--text);
  font: inherit;
}

input:focus-visible,
textarea:focus-visible,
button:focus-visible {
  outline: 2px solid #7ea0ff;
  outline-offset: 2px;
}

.time-field {
  display: grid;
  gap: 8px;
}

.quick-times,
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chip-btn {
  background: #232938;
  border: 1px solid #46506a;
  color: #dbe2ef;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.82rem;
  line-height: 1;
  font-weight: 700;
}

.chip-btn:hover {
  background: #2b3244;
  border-color: #5c6990;
}

#tradeList > div {
  border-top: 1px solid var(--line);
  padding: 11px 0;
}

/* Rex mood widget */
.rex-widget {
  position: fixed;
  left: 12px;
  top: 12px;
  z-index: 1000;
  width: 92px;
  border-radius: 16px;
  border: 1px solid rgba(126, 160, 255, 0.26);
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  backdrop-filter: blur(10px);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.3);
  padding: 8px 8px 6px;
  text-align: center;
}

.rex-face {
  font-size: 2.25rem;
  line-height: 1;
  filter: saturate(1.1);
  animation: rexBob 2.3s ease-in-out infinite;
}

.rex-label {
  margin-top: 5px;
  font-size: 0.68rem;
  color: #d6dced;
  font-weight: 700;
  letter-spacing: 0.15px;
}

.rex-effects {
  position: relative;
  height: 0;
}

.money,
.tear {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.money-1 { left: 8px; top: -24px; }
.money-2 { left: 36px; top: -30px; }
.money-3 { left: 58px; top: -22px; }

.tear-1 { left: 30px; top: -22px; }
.tear-2 { left: 48px; top: -22px; }

.mood-profit .money {
  opacity: 1;
  animation: moneyDrop 1.1s linear infinite;
}

.mood-profit .money-2 { animation-delay: 0.2s; }
.mood-profit .money-3 { animation-delay: 0.45s; }

.mood-profit .rex-face {
  filter: saturate(1.25) drop-shadow(0 0 8px rgba(56, 214, 107, 0.35));
}

.mood-loss .tear {
  opacity: 1;
  animation: tearDrop 0.95s ease-in infinite;
}

.mood-loss .tear-2 { animation-delay: 0.24s; }

.mood-loss .rex-face {
  filter: saturate(0.9);
}

.mood-neutral .rex-face {
  filter: saturate(1.05);
}

@keyframes rexBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

@keyframes moneyDrop {
  0% { transform: translateY(-4px) rotate(-8deg); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translateY(18px) rotate(10deg); opacity: 0; }
}

@keyframes tearDrop {
  0% { transform: translateY(0); opacity: 0.1; }
  20% { opacity: 0.9; }
  100% { transform: translateY(12px); opacity: 0; }
}

.trade-row {
  display: grid;
  gap: 8px;
}

.trade-main {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 1.05rem;
  font-weight: 800;
}

.trade-type {
  text-transform: capitalize;
  font-weight: 900;
}

.trade-time {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.92rem;
}

.trade-note {
  color: var(--muted);
  font-size: 0.92rem;
}

.trade-actions {
  display: flex;
  gap: 8px;
}

.field-wrap {
  margin: 8px 0 12px;
}

.account-modal {
  max-width: 420px;
}

.btn-small {
  padding: 8px 11px;
  font-size: 0.92rem;
}

.btn-edit {
  border-color: #5f6a86;
}

.btn-delete {
  border-color: rgba(255, 94, 115, 0.6);
  color: #ffdbe1;
}

.btn-delete:hover {
  border-color: #ff758a;
}

@keyframes monthSlideIn {
  from {
    opacity: 0;
    transform: translateX(14px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes monthSlideInPrev {
  from {
    opacity: 0;
    transform: translateX(-14px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}