/* =========================================================
   TRADESIM — PREMIUM FINTECH UI
   Mobile-first responsive design
   ========================================================= */

:root {
  --bg: #070a12;
  --bg-soft: #0b101b;
  --surface: #101725;
  --surface-2: #141d2d;
  --surface-3: #192336;

  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.13);

  --text: #f7f9fc;
  --text-soft: #b5bfd0;
  --muted: #7e8aa0;

  --green: #32e58a;
  --green-dark: #0f9f61;
  --green-soft: rgba(50, 229, 138, 0.12);

  --red: #ff6478;
  --red-dark: #d83f58;
  --red-soft: rgba(255, 100, 120, 0.12);

  --blue: #5b8cff;
  --blue-soft: rgba(91, 140, 255, 0.13);

  --purple: #9b7cff;
  --cyan: #45d9e8;

  --shadow-sm:
    0 4px 18px rgba(0, 0, 0, 0.18);

  --shadow:
    0 12px 35px rgba(0, 0, 0, 0.30);

  --shadow-lg:
    0 24px 70px rgba(0, 0, 0, 0.48);

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;

  --ease: 180ms cubic-bezier(.2,.8,.2,1);
}


/* =========================================================
   RESET
   ========================================================= */

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

html {
  scroll-behavior: smooth;
  background: var(--bg);
}

body {
  min-height: 100vh;

  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Arial,
    sans-serif;

  background:
    radial-gradient(
      circle at 8% -5%,
      rgba(91, 140, 255, 0.13),
      transparent 30%
    ),
    radial-gradient(
      circle at 95% 5%,
      rgba(50, 229, 138, 0.08),
      transparent 25%
    ),
    linear-gradient(
      180deg,
      #070a12 0%,
      #080d17 48%,
      #060910 100%
    );

  color: var(--text);
  line-height: 1.45;

  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;

  background:
    linear-gradient(
      rgba(255,255,255,0.012) 1px,
      transparent 1px
    ),
    linear-gradient(
      90deg,
      rgba(255,255,255,0.012) 1px,
      transparent 1px
    );

  background-size: 32px 32px;

  mask-image:
    linear-gradient(
      to bottom,
      black,
      transparent 75%
    );
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button,
input,
select {
  outline: none;
}


/* =========================================================
   MAIN APP
   ========================================================= */

.app {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding-bottom: 105px;
}


/* =========================================================
   HEADER
   ========================================================= */

header {
  position: sticky;
  top: 0;
  z-index: 100;

  padding:
    14px
    max(16px, calc((100vw - 1180px) / 2));

  background:
    linear-gradient(
      180deg,
      rgba(7, 10, 18, 0.96),
      rgba(7, 10, 18, 0.84)
    );

  border-bottom: 1px solid var(--border);

  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.logo {
  position: relative;

  font-size: 24px;
  font-weight: 900;
  letter-spacing: -0.8px;
}

.logo::after {
  content: "";
  position: absolute;

  width: 7px;
  height: 7px;

  right: -10px;
  top: 3px;

  border-radius: 50%;

  background: var(--green);

  box-shadow:
    0 0 12px rgba(50,229,138,.7);
}

.logo span {
  color: var(--green);
}


/* =========================================================
   BADGES
   ========================================================= */

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  min-height: 24px;

  padding: 5px 10px;

  border-radius: 999px;

  background:
    linear-gradient(
      135deg,
      rgba(50,229,138,.16),
      rgba(50,229,138,.07)
    );

  color: #7bf2b2;

  border: 1px solid rgba(50,229,138,.24);

  font-size: 10px;
  font-weight: 800;
  letter-spacing: .7px;
}


/* =========================================================
   ACCOUNT HERO
   ========================================================= */

.balance-card {
  position: relative;
  overflow: hidden;

  margin: 18px 16px;

  padding: 22px;

  border-radius: var(--radius-lg);

  background:
    radial-gradient(
      circle at 90% 0%,
      rgba(91,140,255,.18),
      transparent 35%
    ),
    radial-gradient(
      circle at 10% 100%,
      rgba(50,229,138,.09),
      transparent 30%
    ),
    linear-gradient(
      145deg,
      #121a2a,
      #0d1421
    );

  border: 1px solid var(--border-strong);

  box-shadow: var(--shadow);
}

.balance-card::before {
  content: "";

  position: absolute;

  width: 180px;
  height: 180px;

  right: -100px;
  top: -100px;

  border-radius: 50%;

  background:
    radial-gradient(
      circle,
      rgba(91,140,255,.28),
      transparent 65%
    );

  pointer-events: none;
}

.balance-card .muted {
  position: relative;
  z-index: 1;
}

.balance {
  position: relative;
  z-index: 1;

  margin: 7px 0 20px;

  font-size: clamp(30px, 8vw, 42px);
  font-weight: 900;
  letter-spacing: -1.5px;

  background:
    linear-gradient(
      120deg,
      #ffffff 20%,
      #bcd0ff 80%
    );

  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}


/* =========================================================
   STAT GRID
   ========================================================= */

.stats {
  position: relative;
  z-index: 1;

  display: grid;

  grid-template-columns:
    repeat(2, minmax(0, 1fr));

  gap: 9px;
}

.stat {
  padding: 12px;

  border-radius: 13px;

  background:
    rgba(5, 9, 17, .48);

  border: 1px solid rgba(255,255,255,.055);

  transition:
    transform var(--ease),
    border-color var(--ease),
    background var(--ease);
}

.stat:hover {
  transform: translateY(-2px);
  border-color: rgba(255,255,255,.12);
  background: rgba(10,16,27,.75);
}

.stat-value {
  margin-top: 5px;

  font-size: 15px;
  font-weight: 800;
  letter-spacing: -.2px;
}


/* =========================================================
   TEXT
   ========================================================= */

.muted {
  color: var(--muted);
  font-size: 12px;
}

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

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


/* =========================================================
   SECTIONS
   ========================================================= */

.section {
  padding: 10px 16px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;

  margin:
    6px 2px 13px;

  font-size: 18px;
  font-weight: 850;
  letter-spacing: -.35px;
}


/* =========================================================
   MARKET GRID
   ========================================================= */

.market-grid {
  display: grid;
  gap: 11px;
}


/* =========================================================
   STOCK CARD
   ========================================================= */

.stock-card {
  position: relative;
  overflow: hidden;

  padding: 16px;

  border-radius: var(--radius);

  background:
    linear-gradient(
      145deg,
      rgba(20,29,45,.96),
      rgba(12,18,30,.96)
    );

  border: 1px solid var(--border);

  box-shadow: var(--shadow-sm);

  transition:
    transform var(--ease),
    border-color var(--ease),
    box-shadow var(--ease);
}

.stock-card::before {
  content: "";

  position: absolute;

  left: 0;
  top: 0;

  width: 42%;
  height: 1px;

  background:
    linear-gradient(
      90deg,
      rgba(91,140,255,.8),
      transparent
    );

  opacity: .8;
}

.stock-card:hover {
  transform: translateY(-3px);

  border-color:
    rgba(91,140,255,.22);

  box-shadow:
    0 14px 38px rgba(0,0,0,.35);
}

.stock-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;

  gap: 16px;
}

.stock-name {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -.2px;
}

.symbol {
  margin-top: 4px;

  color: var(--muted);

  font-size: 11px;
  font-weight: 700;
  letter-spacing: .6px;
}

.stock-price {
  text-align: right;

  font-size: 17px;
  font-weight: 900;

  white-space: nowrap;
}

.stock-change {
  margin-top: 4px;

  text-align: right;

  font-size: 11px;
  font-weight: 700;
}


/* =========================================================
   BUTTONS
   ========================================================= */

.stock-actions {
  display: flex;
  gap: 9px;

  margin-top: 15px;
}

.btn {
  flex: 1;

  min-height: 43px;

  border: 1px solid transparent;
  border-radius: 11px;

  padding: 10px 12px;

  font-size: 13px;
  font-weight: 850;

  transition:
    transform var(--ease),
    filter var(--ease),
    box-shadow var(--ease),
    background var(--ease);
}

.btn:active {
  transform: scale(.97);
}

.btn:hover {
  filter: brightness(1.08);
}

.buy-btn {
  color: white;

  background:
    linear-gradient(
      135deg,
      #19a968,
      #0d8051
    );

  box-shadow:
    0 7px 18px rgba(25,169,104,.16);
}

.sell-btn {
  color: white;

  background:
    linear-gradient(
      135deg,
      #dc4c63,
      #ad3049
    );

  box-shadow:
    0 7px 18px rgba(220,76,99,.14);
}


/* =========================================================
   PORTFOLIO / ORDERS
   ========================================================= */

.portfolio-card,
.order-card {
  position: relative;
  overflow: hidden;

  padding: 16px;
  margin-bottom: 10px;

  border-radius: var(--radius);

  background:
    linear-gradient(
      145deg,
      rgba(18,26,40,.97),
      rgba(11,17,28,.97)
    );

  border: 1px solid var(--border);

  box-shadow: var(--shadow-sm);

  transition:
    transform var(--ease),
    border-color var(--ease);
}

.portfolio-card:hover,
.order-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
}

.position-row,
.order-row {
  display: flex;

  align-items: center;
  justify-content: space-between;

  gap: 12px;
}

.position-main strong,
.order-row strong {
  display: block;

  font-size: 14px;
  font-weight: 850;
}

.position-main small {
  display: block;

  margin-top: 3px;

  color: var(--muted);

  font-size: 11px;
}


/* =========================================================
   EMPTY STATES
   ========================================================= */

.empty {
  padding: 32px 15px;

  text-align: center;

  color: var(--muted);

  border:
    1px dashed rgba(255,255,255,.10);

  border-radius: var(--radius);

  background:
    rgba(255,255,255,.015);
}


/* =========================================================
   MODAL
   ========================================================= */

.modal-overlay {
  position: fixed;
  inset: 0;

  z-index: 500;

  display: none;

  align-items: flex-end;
  justify-content: center;

  padding: 0;

  background:
    rgba(2,4,8,.78);

  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal-overlay.show {
  display: flex;
}

.modal {
  width: 100%;
  max-width: 540px;

  padding: 22px;

  border-radius:
    24px 24px 0 0;

  background:
    linear-gradient(
      145deg,
      #151e2e,
      #0d1421
    );

  border:
    1px solid rgba(255,255,255,.10);

  border-bottom: 0;

  box-shadow: var(--shadow-lg);

  animation:
    modalUp 220ms cubic-bezier(.2,.8,.2,1);
}

@keyframes modalUp {
  from {
    transform: translateY(35px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal h2 {
  margin-bottom: 4px;

  font-size: 21px;
  font-weight: 900;
  letter-spacing: -.5px;
}

.modal-stock {
  margin-bottom: 19px;

  color: var(--text-soft);

  font-size: 13px;
  font-weight: 650;
}


/* =========================================================
   FORM
   ========================================================= */

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;

  margin-bottom: 7px;

  color: var(--text-soft);

  font-size: 12px;
  font-weight: 700;
}

.form-group input,
.form-group select {
  width: 100%;

  min-height: 46px;

  padding: 11px 13px;

  color: var(--text);

  background:
    #090f1a;

  border:
    1px solid rgba(255,255,255,.10);

  border-radius: 11px;

  transition:
    border-color var(--ease),
    box-shadow var(--ease),
    background var(--ease);
}

.form-group input:focus,
.form-group select:focus {
  border-color:
    rgba(91,140,255,.75);

  background: #0b1220;

  box-shadow:
    0 0 0 3px rgba(91,140,255,.12);
}

.form-group select {
  appearance: auto;
}


/* =========================================================
   ORDER ESTIMATE
   ========================================================= */

.estimate {
  display: flex;
  align-items: center;
  justify-content: space-between;

  gap: 15px;

  margin: 14px 0;

  padding: 14px;

  border-radius: 12px;

  background:
    linear-gradient(
      135deg,
      rgba(91,140,255,.10),
      rgba(91,140,255,.035)
    );

  border:
    1px solid rgba(91,140,255,.13);

  color: var(--text-soft);

  font-size: 12px;
}

.estimate strong {
  color: white;

  font-size: 17px;
  font-weight: 900;
}


/* =========================================================
   MODAL ACTIONS
   ========================================================= */

.modal-actions {
  display: flex;
  gap: 9px;

  margin-top: 5px;
}

.cancel-btn,
.confirm-btn {
  flex: 1;

  min-height: 46px;

  border-radius: 11px;

  padding: 12px;

  font-weight: 850;

  transition:
    transform var(--ease),
    filter var(--ease),
    background var(--ease);
}

.cancel-btn {
  color: var(--text-soft);

  background:
    rgba(255,255,255,.035);

  border:
    1px solid rgba(255,255,255,.10);
}

.cancel-btn:hover {
  color: white;
  background: rgba(255,255,255,.07);
}

.confirm-btn {
  color: white;

  background:
    linear-gradient(
      135deg,
      #19a968,
      #0d8051
    );

  border: 0;

  box-shadow:
    0 9px 25px rgba(25,169,104,.18);
}

.confirm-btn:hover {
  filter: brightness(1.08);
}

.cancel-btn:active,
.confirm-btn:active {
  transform: scale(.98);
}


/* =========================================================
   BOTTOM NAVIGATION
   ========================================================= */

.bottom-nav {
  position: fixed;

  left: 10px;
  right: 10px;
  bottom: 10px;

  z-index: 200;

  display: grid;

  grid-template-columns:
    repeat(4, 1fr);

  padding: 7px;

  border-radius: 18px;

  background:
    rgba(15,22,35,.90);

  border:
    1px solid rgba(255,255,255,.10);

  box-shadow:
    0 18px 45px rgba(0,0,0,.48);

  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.nav-btn {
  position: relative;

  min-height: 52px;

  border: 0;
  border-radius: 13px;

  background: transparent;

  color: #7f8ba1;

  padding: 6px 2px;

  font-size: 10px;
  font-weight: 750;

  transition:
    color var(--ease),
    background var(--ease),
    transform var(--ease);
}

.nav-btn:hover {
  color: white;
  background: rgba(255,255,255,.045);
}

.nav-btn:active {
  transform: scale(.95);
}

.nav-btn.active {
  color: var(--green);

  background:
    linear-gradient(
      135deg,
      rgba(50,229,138,.13),
      rgba(50,229,138,.045)
    );
}

.nav-btn.active::after {
  content: "";

  position: absolute;

  width: 4px;
  height: 4px;

  bottom: 4px;
  left: 50%;

  transform: translateX(-50%);

  border-radius: 50%;

  background: var(--green);

  box-shadow:
    0 0 9px rgba(50,229,138,.75);
}


/* =========================================================
   DISCLAIMER
   ========================================================= */

.disclaimer {
  max-width: 720px;

  margin: 5px auto 0;

  padding: 20px 18px;

  color: #68758a;

  text-align: center;

  font-size: 10px;
  line-height: 1.6;
}


/* =========================================================
   FOCUS ACCESSIBILITY
   ========================================================= */

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}


/* =========================================================
   TABLET
   ========================================================= */

@media (min-width: 600px) {

  .balance-card {
    margin-top: 24px;
  }

  .market-grid {
    grid-template-columns:
      repeat(2, minmax(0, 1fr));
  }

}


/* =========================================================
   DESKTOP
   ========================================================= */

@media (min-width: 850px) {

  .app {
    padding-bottom: 40px;
  }

  header {
    padding-top: 18px;
    padding-bottom: 18px;
  }

  .balance-card {
    margin:
      28px 16px 22px;
    padding: 28px;
  }

  .stats {
    grid-template-columns:
      repeat(4, minmax(0, 1fr));

    gap: 12px;
  }

  .stat {
    padding: 15px;
  }

  .market-grid {
    grid-template-columns:
      repeat(3, minmax(0, 1fr));

    gap: 13px;
  }

  .section {
    padding-top: 13px;
  }

  .bottom-nav {
    left: 50%;
    right: auto;
    bottom: 16px;

    width: 470px;

    transform: translateX(-50%);
  }

  .modal-overlay {
    align-items: center;
    padding: 20px;
  }

  .modal {
    border-radius: 22px;
    border: 1px solid rgba(255,255,255,.10);
  }

}


/* =========================================================
   LARGE DESKTOP
   ========================================================= */

@media (min-width: 1150px) {

  .balance-card {
    margin-left: 16px;
    margin-right: 16px;
  }

  .market-grid {
    grid-template-columns:
      repeat(3, 1fr);
  }

}


/* =========================================================
   REDUCED MOTION
   ========================================================= */

@media (prefers-reduced-motion: reduce) {

  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }

}
