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

:root {
  --primary: #2563eb;
  --primary-dark: #1e40af;
  --primary-light: #3b82f6;
  --secondary: #06b6d4;
  --bg-main: #0f172a;
  --bg-card: #1e293b;
  --bg-hover: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border: #334155;
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.4);
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: var(--bg-main);
  font-family: 'Poppins', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text-primary);
  overflow-x: hidden;
}

/* Navigation Sidebar */
nav {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: 260px;
  background: linear-gradient(180deg, var(--bg-card) 0%, #0f172a 100%);
  backdrop-filter: blur(10px);
  border-right: 1px solid var(--border);
  z-index: 1000;
  transition: transform 0.3s ease;
  overflow-y: auto;
}

nav ul {
  list-style: none;
  padding: 4rem 0;
  margin: 0;
}

nav li {
  margin: 1rem 1rem;
  transition: transform 0.2s ease;
}

nav li:hover {
  transform: translateX(5px);
}

nav a {
  display: block;
  padding: 1rem 1.5rem;
  text-decoration: none;
  color: var(--text-secondary);
  border-radius: 12px;
  font-weight: 500;
  font-size: 0.95rem;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

nav a::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--primary);
  transform: scaleY(0);
  transition: transform 0.3s ease;
}

nav a:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

nav a:hover::before {
  transform: scaleY(1);
}

nav li a b {
  color: var(--primary-light);
}

.trader-sim {
  display: block;
  padding: 1rem 1.5rem;
  text-decoration: none;
  color: var(--primary-light);
  border-radius: 12px;
  font-weight: 900;
  font-size: 1.25rem;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

/* Hamburger Menu Button */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 6px;
  width: 1.5rem;
  height: 1.5rem;
  background: transparent;
  border: none;
  cursor: pointer;
}

.nav-toggle span {
  display: block;
  height: 3px;
  width: 100%;
  background-color: var(--text-primary);
  border-radius: 2px;
  transition: all 0.3s ease;
}

.nav-toggle.active span:nth-child(1) {
    transform: translateY(9px) rotate(45deg);
}

.nav-toggle.active span:nth-child(2) {
    opacity: 0;
}

.nav-toggle.active span:nth-child(3) {
    transform: translateY(-9px) rotate(-45deg);
}

.nav-toggle-wrapper {
  display: none;
  top: 1rem;
  left: 1rem;
  width: 40px;
  height: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 1100;
}

.nav-toggle-wrapper:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--secondary) 100%);
}

.nav-toggle-wrapper:active {
  transform: translateY(0);
}

#admin-panel {
  display: none;
}

/* Main Content */
main {
  margin-left: 260px;
  padding: 2rem;
  min-height: 100vh;
  transition: margin-left 0.3s ease;
}

main h1 {
  font-size: 2.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 2rem;
  animation: fadeInDown 0.6s ease;
}

main h2, main h3 {
  color: var(--text-primary);
  margin: 1.5rem 0 1rem;
  font-weight: 600;
}

/* Top Right */
.sign-message, .top-right {
  position: absolute;
  top: 2rem;
  right: 2rem;
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--text-secondary);
  z-index: 100;
}

.sign-message a {
  color: var(--primary-light);
  text-decoration: none;
  transition: color 0.3s ease;
}

.sign-message a:hover {
  color: var(--secondary);
}

.log-out {
  position: absolute;
  top: 4rem;
  right: 2rem;
  padding: 0.6rem 1.5rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 1rem;
  width: auto;
}

.log-out:hover {
  background: var(--error);
  border-color: var(--error);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

#greeting {
  color: var(--text-primary);
  font-size: 1.75rem;
  font-weight: 700;
  margin: 2rem 0;
  animation: fadeIn 0.8s ease;
}

#balance {
  font-size: 1.50rem;
}

.text-style {
  color: var(--text-primary);
}

/* Forms */
form {
  background: var(--bg-card);
  padding: 1.5rem;
  border-radius: 16px;
  box-shadow: var(--shadow);
  margin: 1.5rem 0;
  border: 1px solid var(--border);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

form:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

input, select {
  width: 50%;
  padding: 0.75rem 1rem;
  margin: 0.5rem 0;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.95rem;
  transition: all 0.3s ease;
  font-family: inherit;
}

#create-stock input {
  max-width: 350px;
}

#deposit-amount, #withdraw-amount {
  width: 500px;
}

#open-time, #close-time {
  width: 180px;
}

input[type="time"] {
  color-scheme: dark;
  cursor: pointer;
}

input[type="time"]::-webkit-calendar-picker-indicator {
  filter: invert(0.7);
  cursor: pointer;
  font-size: 1.1rem;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

input::placeholder {
  color: var(--text-muted);
}

button[type="submit"], button {
  max-width: 200px;
  padding: 0.875rem 1.5rem;
  margin-top: 1rem;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

button[type="submit"]:hover, button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--secondary) 100%);
}

button[type="submit"]:active {
  transform: translateY(0);
}

.cancel-btn {
  background: transparent;
  border: 2px solid var(--error);
  color: var(--error);
  width: auto;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  margin: 0;
  font-weight: 700;
  max-width: none;
}

.cancel-btn:hover {
  background: var(--error);
  border-color: var(--error);
  color: white;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

#shares, #sell-shares {
  width: 240px;
  display: inline-block;
  margin-right: 1rem;
  max-width: none;
}

#ticker, #sell-ticker {
  width: 240px;
  display: inline-block;
  margin-right: 1rem;
  max-width: none;
}

/* Tables */
#stocks-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 2rem 0;
  background: var(--bg-card);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  animation: fadeInUp 0.6s ease;
}

#stocks-table thead {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
}

#stocks-table th {
  padding: 1.25rem 1.5rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: white;
}

#stocks-table td {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.95rem;
}

#stocks-table tbody tr {
  transition: all 0.3s ease;
  background: var(--bg-card);
}

#stocks-table tbody tr:nth-child(odd) {
  background: #1a2332;
}

#stocks-table tbody tr:nth-child(even) {
  background: var(--bg-card);
}

#stocks-table tbody tr:hover {
  background: var(--bg-hover);
  transform: scale(1.01);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

#stocks-table tbody tr:last-child td {
  border-bottom: none;
}

/* Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 34px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--success);
  transition: 0.4s;
  border-radius: 34px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.slider:before {
  position: absolute;
  content: "";
  height: 26px;
  width: 26px;
  left: 4px;
  bottom: 4px;
  background: white;
  transition: 0.4s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input:checked + .slider {
  background: var(--error);
}

input:checked + .slider:before {
  transform: translateX(26px);
}

.market-message {
  font-size: 1.2rem;
  margin-left: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Messages */
.msg, #buy-msg, #sell-msg, #deposit-msg, #withdraw-msg, #schedule-msg {
  margin-top: 1rem;
  padding: 0.875rem 1.25rem;
  border-radius: 8px;
  font-weight: 700;
  font-size: 1.25rem;
  animation: fadeIn 0.3s ease;
}

#schedule-msg:empty, #buy-msg:empty, #sell-msg:empty, #deposit-msg:empty, #withdraw-msg:empty {
  display: none;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-height: 800px) {
  nav ul {
    padding: 12rem 0;
  }
}

/* Mobile Responsiveness */
@media (max-width: 1200px) {
  .hide-mobile {
    display: none !important;
  }
  
  /* Show hamburger */
  .nav-toggle {
    display: flex;
  }

  .nav-toggle-wrapper {
  display: flex;
  position: fixed;
  }

  /* Sidebar*/
  nav {
    transform: translateX(-100%);
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: 240px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    transition: transform 0.3s ease;
    z-index: 1000;
  }

  nav.open {
    transform: translateX(0);
  }

  nav ul {
    display: flex;
    flex-direction: column;
    padding: 5rem 1rem;
  }

  nav li {
    margin: 0.5rem 0;
  }

  main {
    margin-left: 0;
    padding: 1rem;
    padding-top: 5rem;
  }

  /* Dim background when nav open */
  body.nav-open::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
  }

  main h1 {
    font-size: 1.75rem;
  }
  
  .sign-message, .top-right {
    top: 1rem;
    right: 1rem;
    font-size: 0.85rem;
  }
  
  .log-out {
    top: 2rem;
    right: 1rem;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
  }
  
  form {
    padding: 1.5rem;
  }
  
  input,
  select {
    width: 100%;
    max-width: 320px;
    padding: 0.6rem 0.9rem;
    font-size: 0.9rem;
    box-sizing: border-box;
  }

  #deposit-amount,
  #withdraw-amount {
    width: 100%;
    max-width: 320px;
  }
  
  #open-time,
  #close-time {
    display: block;
    width: 100%;
    max-width: 300px;
  }

  #open-time {
    margin: 1rem 0;  
  }  
  
  #save-schedule {
    margin-top: 0rem !important;
    margin-bottom: 0rem
  }

  #shares, #sell-shares, #ticker, #sell-ticker {
    width: 100%;
    margin: 0.5rem 0;
  }

  .cancel-btn {
    padding: 0.1rem 0.4rem;
    font-size: 0.75rem;
    border-width: 1px;
    transform: translateZ(0);
  }

  .cancel-btn:hover {
    transform: none;
    box-shadow: none;
  }
  
  #stocks-table {
    border: none;
    background: transparent;
  }

  #stocks-table thead {
    display: none;
  }

  #stocks-table, 
  #stocks-table tbody, 
  #stocks-table tr, 
  #stocks-table td {
    display: block;
    width: 100%;
  }

  #stocks-table tbody tr:hover {
    background: var(--bg-hover);
    transform: translateY(-2px);
    transition: all 0.2s ease;
  }

  #stocks-table td::before {
    content: attr(data-label) ": ";
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
    opacity: 0.85;
  }

  #stocks-table {
    margin-top: 1rem;
  }

  #stocks-table tbody {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
  }

  #stocks-table tr {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    padding: 0.6rem 0.8rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
  }

  #stocks-table td {
    display: flex;
    justify-content: flex-start; 
    flex-wrap: wrap; 
    font-size: 0.8rem;
    padding: 0.2rem 0;
    line-height: 1.1;
    gap: 0.3rem 0.5rem;
  }
}

@media (max-width: 480px) {
  main h1 {
    font-size: 1.5rem;
  }
  
  #stocks-table th, #stocks-table td {
    padding: 0.875rem 1rem;
    font-size: 0.85rem;
  }
  
  button[type="submit"], button {
    font-size: 0.9rem;
  }
   #stocks-table tbody {
    gap: 0.5rem;
  }

  #stocks-table tr {
    padding: 0.5rem 0.6rem;
    border-radius: 8px;
  }

  #stocks-table td {
    font-size: 0.8rem;
    line-height: 1.1;
    padding: 0.15rem 0;
  }

  #stocks-table td::before {
    font-size: 0.7rem;
    opacity: 0.8;
  }

  /* Inputs fit narrow screens */
  input,
  select {
    width: 100%;
    max-width: 280px;
    padding: 0.45rem 0.8rem;
    font-size: 0.85rem;
  }

  /* Compact buttons */

  .top-right,
  .sign-message {
    top: 0.6rem;
    right: 0.8rem;
    font-size: 0.7rem;
  }

  .log-out {
    top: 1.25rem;
    right: 0.8rem;
    padding: 0.3rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 6px;
  }

  .nav-toggle-wrapper {
    width: 32px;
    height: 32px;
    top: 0.6rem;
    left: 0.6rem;
    border-radius: 6px;
  }

  .nav-toggle span {
    height: 2px;
  }

  main {
    padding: 0.8rem;
    padding-top: 4rem;
  }
}

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-main);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}