@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root { --fab-size: 60px; }

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: linear-gradient(135deg, #0f0f23, #1a1a2e 50%, #16213e 100%);
  min-height: 100vh; color: #ffffff; overflow-x: hidden;
}

/* A11y helper to hide native date input in daily card */
.visually-hidden {
  position: absolute !important; width: 1px !important; height: 1px !important;
  padding: 0 !important; margin: -1px !important; overflow: hidden !important;
  clip: rect(0 0 0 0) !important; white-space: nowrap !important; border: 0 !important;
}

.background-pattern {
  position: fixed; inset: 0; opacity: 0.03; z-index: -1;
  background-image:
    radial-gradient(circle at 25% 25%, #ffffff 2px, transparent 2px),
    radial-gradient(circle at 75% 75%, #ffffff 1px, transparent 1px);
  background-size: 50px 50px;
}
.container {
  max-width: 1400px; margin: 0 auto; padding: 2rem;
  padding-bottom: calc(var(--fab-size) + 40px + env(safe-area-inset-bottom, 0));
}

.header { 
  text-align: center; 
  margin-bottom: 3rem; 
  position: relative; 
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.header h1 {
  font-size: 3.2rem; font-weight: 800;
  background: linear-gradient(135deg, #ff6b6b 0%, #4ecdc4 50%, #45b7d1 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  margin-bottom: 1rem; letter-spacing: -1.5px;
}
.header p { font-size: 1.1rem; opacity: 0.85; font-weight: 300; }

/* Loading Screen */
.loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #0f0f23, #1a1a2e 50%, #16213e 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
}

.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(78, 205, 196, 0.2);
  border-top: 3px solid #4ecdc4;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

.loading-text {
  color: #4ecdc4;
  font-size: 1.1rem;
  font-weight: 500;
}

/* Infinite scroll loading indicator */
.loading-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  margin: 2rem 0;
}

.loading-spinner-small {
  width: 30px;
  height: 30px;
  border: 3px solid rgba(78, 205, 196, 0.2);
  border-top: 3px solid #4ecdc4;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 12px;
}

.loading-text-small {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.9rem;
  font-weight: 500;
  text-align: center;
}

/* Login Screen */
.login-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #0f0f23, #1a1a2e 50%, #16213e 100%); /* Full-page background like main app */
  display: none; /* Hidden by default */
  align-items: center;
  justify-content: center;
  z-index: 2001; /* Higher than session modal */
}

.login-container {
  width: 100%;
  max-width: 420px;
  padding: 2rem;
  position: relative;
}

.login-header {
  text-align: center;
  margin-bottom: 3rem;
  position: relative;
}

.login-header::before {
  content: '';
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  width: 100px;
  height: 4px;
  background: linear-gradient(90deg, #ff6b6b, #4ecdc4, #45b7d1);
  border-radius: 2px;
}

.login-header h1 {
  font-size: 2.8rem;
  font-weight: 800;
  background: linear-gradient(135deg, #ff6b6b 0%, #4ecdc4 50%, #45b7d1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 1rem;
  letter-spacing: -1.5px;
}

.login-header p {
  font-size: 1rem;
  opacity: 0.85;
  font-weight: 300;
}

.login-form-card {
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  padding: 2.5rem;
  position: relative;
  overflow: hidden;
}

.login-form-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #4ecdc4, #45b7d1, #ff6b6b);
}

.login-form-card h2 {
  font-size: 1.8rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 0.5rem;
  color: #ffffff;
}

.login-subtitle {
  text-align: center;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.95rem;
  margin-bottom: 2rem;
  font-weight: 300;
}

.login-form .form-group {
  margin-bottom: 1.5rem;
}

.login-form label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: rgba(255, 255, 255, 0.9);
}

.login-form input[type="email"],
.login-form input[type="password"] {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  color: #ffffff;
  font-size: 1rem;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.login-form input[type="email"]:focus,
.login-form input[type="password"]:focus {
  outline: none;
  border-color: #4ecdc4;
  background: rgba(255, 255, 255, 0.12);
}

.login-form input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.login-btn {
  width: 100%;
  padding: 14px 16px;
  border: 0;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  color: #0b141a;
  background: linear-gradient(135deg, #4ecdc4, #45b7d1);
  box-shadow: 0 8px 24px rgba(78, 205, 196, 0.35);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-btn:hover {
  filter: brightness(1.05);
  box-shadow: 0 10px 28px rgba(78, 205, 196, 0.5);
}

.login-btn:active {
  transform: translateY(1px);
}

.login-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.login-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(11, 20, 26, 0.3);
  border-top: 2px solid #0b141a;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.login-error {
  background: rgba(255, 107, 107, 0.15);
  border: 1px solid rgba(255, 107, 107, 0.3);
  color: #ff6b6b;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  text-align: center;
}

/* Hide main app when showing login */
.login-active #mainApp {
  display: none;
}

/* Hide add session button when showing login */
.login-active .add-session-btn {
  display: none;
}

.btn {
  border: 1px solid rgba(255,255,255,0.25); background: rgba(255,255,255,0.08); color: #fff;
  padding: 6px 10px; border-radius: 10px; font-size: 12px; cursor: pointer; line-height: 1; font-weight: 600;
}
.btn:hover { background: rgba(255,255,255,0.16); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

/* Primary form submit button (Add Entry / Save Changes) */
.submit-btn {
  width: 100%;
  margin-top: 10px;
  padding: 12px 16px;
  border: 0;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 800;
  color: #0b141a;
  background: linear-gradient(135deg, #4ecdc4, #45b7d1);
  box-shadow: 0 8px 24px rgba(78,205,196,0.35);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.submit-btn:hover { filter: brightness(1.05); box-shadow: 0 10px 28px rgba(78,205,196,0.5); }
.submit-btn:active { transform: translateY(1px); }

/* Menu button (visible at all sizes) */
.mobile-menu-btn {
  display: inline-flex;
  position: absolute; z-index: 20;
  right: calc(env(safe-area-inset-right, 0) + 12px);
  top: calc(env(safe-area-inset-top, 0) + 12px);
  border: 1px solid rgba(255,255,255,0.25); background: rgba(255,255,255,0.08); color: #fff;
  padding: 10px 12px; border-radius: 10px; font-size: 18px; line-height: 1; cursor: pointer;
}
.more-menu {
  display: none; position: absolute; top: 56px; right: calc(env(safe-area-inset-right, 0) + 8px); z-index: 21;
  min-width: 240px; padding: 6px; border-radius: 12px;
  background: rgba(20, 20, 30, 0.9); border: 1px solid rgba(255,255,255,0.15);
  backdrop-filter: blur(10px); box-shadow: 0 12px 30px rgba(0,0,0,0.35);
}
.more-menu .menu-item {
  width: 100%; text-align: left; padding: 12px 14px; border: 0; border-radius: 8px;
  background: transparent; color: #fff; font-weight: 700; cursor: pointer;
}
.more-menu .menu-item:hover { background: rgba(255,255,255,0.12); }
.more-menu .menu-item[disabled] { opacity: 0.45; cursor: not-allowed; }
.menu-backdrop { display: none; position: fixed; inset: 0; z-index: 20; background: transparent; }

/* Hidden file input */
.hidden-file-input { display: none; }

/* Menu separator */
.menu-separator {
  border-color: rgba(255,255,255,0.12);
  border-style: solid;
  border-width: 0 0 1px;
  margin: 6px 8px;
}

/* Stats grid */
.stats-container {
  display: grid; 
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 2rem; 
  margin-bottom: 3rem;
  justify-content: center;
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
}

/* Limit to 4 columns max on larger screens */
@media (min-width: 1200px) {
  .stats-container {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Casino P&L Cards Container */
.casino-cards-container {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 2rem;
  margin-top: 1rem;
}

/* Limit casino cards to 4 columns max on larger screens */
@media (min-width: 1200px) {
  .casino-cards-container {
    grid-template-columns: repeat(4, 1fr);
  }
}
.stat-card {
  background: rgba(255,255,255,0.05); backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.1); border-radius: 24px; padding: 1.5rem; position: relative; overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  display: flex;
  flex-direction: column;
  height: 240px;
  justify-content: center;
  align-items: center;
}

/* Only apply hover effects on devices that support hover (desktop/mouse) */
@media (hover: hover) and (pointer: fine) {
  .stat-card:hover { 
    transform: translateY(-8px); 
    box-shadow: 0 25px 50px rgba(0,0,0,0.3); 
  }
}
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--accent-color), rgba(255,255,255,0.1));
}
.stat-card.profit { --accent-color: #4ecdc4; }
.stat-card.daily { --accent-color: #45b7d1; }
.stat-card.weekly { --accent-color: #7dd3fc; }
.stat-card.monthly { --accent-color: #f59e0b; }
.stat-card.avg-play-day { --accent-color: #a78bfa; }
.stat-card.avg-weekdays { --accent-color: #a78bfa; }
.stat-card.avg-calendar-day { --accent-color: #7dd3fc; }
.stat-card.avg-per-day-monthly { --accent-color: #f59e0b; }
.stat-card.total-days-played { --accent-color: #45b7d1; }
.stat-card.total-weekdays-since-start { --accent-color: #45b7d1; }
.stat-card.total-days-since-start { --accent-color: #7dd3fc; }
.stat-card.casino-pl { --accent-color: #10b981; }
.stat-card.streak-win { --accent-color: #4ecdc4; }
.stat-card.streak-loss { --accent-color: #ff6b6b; }
.stat-card.streak-play { --accent-color: #45b7d1; }
.stat-card.streak-current { --accent-color: #ff6b35; }
.stat-card.winrate { --accent-color: #ffd93d; }
.stat-card.record-best-day { --accent-color: #4ecdc4; }
.stat-card.record-worst-day { --accent-color: #ff6b6b; }
.stat-card.record-best-week { --accent-color: #4ecdc4; }
.stat-card.record-worst-week { --accent-color: #ff6b6b; }
.stat-card.record-best-month { --accent-color: #4ecdc4; }
.stat-card.record-worst-month { --accent-color: #ff6b6b; }
.stat-card.record-best-casino-month { --accent-color: #10b981; }
.stat-card.record-worst-casino-month { --accent-color: #ff6b6b; }
.stat-icon { 
  width: 42px; 
  height: 42px; 
  opacity: 0.8; 
  flex-shrink: 0; 
  position: absolute;
  top: 1.5rem;
  left: 1.5rem;
}
.stat-value { 
  font-size: 2rem; 
  font-weight: 700; 
  margin-bottom: 0.5rem; 
  line-height: 1.2; 
  text-align: center; 
  word-break: break-word; 
  overflow-wrap: break-word; 
  flex-shrink: 0; 
}
.stat-label { 
  font-size: 0.85rem; 
  opacity: 0.75; 
  text-transform: uppercase; 
  letter-spacing: 1px; 
  font-weight: 500; 
  text-align: center; 
  flex-shrink: 0; 
}

/* Record card specific formatting */
.record-value { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.5rem; flex-shrink: 0; }
.record-amount { 
  font-size: 2rem; 
  font-weight: 700; 
  margin-bottom: 0.5rem; 
  margin-top: 0rem; 
  text-align: center; 
  word-break: break-word; 
  overflow-wrap: break-word; 
  flex-shrink: 0; 
}
.record-date { 
  font-size: 0.75rem; 
  opacity: 0.75; 
  margin-top: 0.5rem; 
  text-align: center; 
  color: rgba(255, 255, 255, 0.65); 
  flex-shrink: 0; 
}
.record-date.positive { color: #4ecdc4; opacity: 0.9; }
.record-date.negative { color: #ff6b6b; opacity: 0.9; }
.record-casino { 
  font-size: 0.85rem; 
  font-weight: 600; 
  color: #4ecdc4; 
  margin-top: 0.5rem; 
  text-overflow: ellipsis; 
  overflow: hidden; 
  white-space: nowrap; 
  text-align: center; 
  flex-shrink: 0; 
}
.casino-name { 
  font-size: 0.75rem; 
  opacity: 0.85; 
  margin-top: 0rem; 
  text-align: center; 
  font-weight: 600; 
  color: #4ecdc4; 
  text-overflow: ellipsis; 
  overflow: hidden; 
  white-space: nowrap; 
  flex-shrink: 0; 
}

/* Date footers with chevrons — allow wrapping for better fit */
.stat-card.daily, .stat-card.weekly, .stat-card.monthly, .stat-card.casino-pl, .stat-card.avg-per-day-monthly { 
  padding-bottom: 4.5rem;
  padding-top: 1.5rem;
}
.daily-date, .weekly-date, .monthly-date, .casino-date, .monthly-avg-date {
  position: absolute; left: 16px; right: 16px; bottom: 18px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 0.88rem; opacity: 0.95; text-align: center; min-height: 2.2rem;
  flex-wrap: wrap; /* allow wrapping */
}

/* Label flexes but allows wrapping, buttons are fixed-size */
.daily-date .date-label, .weekly-date .date-label, .monthly-date .date-label, .casino-date .date-label, .monthly-avg-date .date-label {
  flex: 1 1 auto; min-width: 0; text-align: center; line-height: 1.3;
}
.daily-date .nav-btn, .weekly-date .nav-btn, .monthly-date .nav-btn, .casino-date .nav-btn, .monthly-avg-date .nav-btn { flex: 0 0 auto; }

.daily-date .date-label, .weekly-date .date-label, .monthly-date .date-label, .casino-date .date-label, .monthly-avg-date .date-label {
  border-bottom: 1px dashed rgba(255,255,255,0.25);
}
.daily-date .date-label { cursor: pointer; }
.weekly-date .date-label, .monthly-date .date-label, .casino-date .date-label, .monthly-avg-date .date-label { cursor: default; }

.daily-date .nav-btn, .weekly-date .nav-btn, .monthly-date .nav-btn, .casino-date .nav-btn, .monthly-avg-date .nav-btn {
  width: 24px; height: 24px; border-radius: 999px;
  border: 1px solid rgba(167,139,250,0.8); color: rgba(167,139,250,0.95);
  background: transparent; display: grid; place-items: center;
  font-size: 12px; line-height: 1; cursor: pointer;
}
.daily-date .nav-btn:hover, .weekly-date .nav-btn:hover, .monthly-date .nav-btn:hover, .casino-date .nav-btn:hover, .monthly-avg-date .nav-btn:hover { background: rgba(167,139,250,0.12); }
.daily-date .nav-btn:active, .weekly-date .nav-btn:active, .monthly-date .nav-btn:active, .casino-date .nav-btn:active, .monthly-avg-date .nav-btn:active { transform: scale(0.96); }
.daily-date .nav-btn:disabled, .weekly-date .nav-btn:disabled, .monthly-date .nav-btn:disabled, .casino-date .nav-btn:disabled, .monthly-avg-date .nav-btn:disabled { opacity: 0.40; cursor: not-allowed; }

/* Money sign kerning guard */
#dailyPL, #weeklyPL, #monthlyPL { white-space: nowrap; font-kerning: none; font-feature-settings: "kern" 0, "liga" 0; }
#dailyPL .money-sign, #weeklyPL .money-sign, #monthlyPL .money-sign { display: inline-block; margin-right: 4px; transform: translateY(-1px); }

/* Chart */
.chart-section { margin: 2.5rem 0; }

/* Chart Controls */
.chart-controls {
  background: rgba(255,255,255,0.03);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  padding: 1rem 1.2rem;
  margin-bottom: 1rem;
}

.chart-controls-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  text-align: center;
  opacity: 0.9;
  color: #ffffff;
}

.chart-controls-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.chart-filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

/* Month Navigation */
.chart-month-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chart-nav-btn {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  color: #ffffff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-nav-btn:hover:not(:disabled) {
  background: rgba(78,205,196,0.2);
  border-color: #4ecdc4;
  transform: scale(1.05);
}

.chart-nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.chart-month-label {
  font-weight: 600;
  font-size: 0.9rem;
  min-width: 120px;
  text-align: center;
  color: #ffffff;
  opacity: 0.9;
}

/* View Controls */
.chart-view-controls {
  display: flex;
  gap: 2px;
  background: rgba(255,255,255,0.05);
  border-radius: 8px;
  padding: 2px;
}

.chart-view-btn {
  background: transparent;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  color: #ffffff;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  opacity: 0.7;
}

.chart-view-btn.active,
.chart-view-btn:hover {
  background: rgba(78,205,196,0.2);
  opacity: 1;
}

.chart-view-btn.active {
  background: #4ecdc4;
  color: #ffffff;
}

/* Daily Aggregation Toggle */
.chart-aggregation-toggle {
  display: flex;
  gap: 0.5rem;
}

.chart-toggle-btn {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  padding: 8px 14px;
  color: #ffffff;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: 0.7;
}

.chart-toggle-btn:hover {
  background: rgba(78,205,196,0.2);
  border-color: #4ecdc4;
  opacity: 1;
}

.chart-toggle-btn.active {
  background: #4ecdc4;
  border-color: #4ecdc4;
  color: #ffffff;
  opacity: 1;
}

.chart-toggle-btn .toggle-icon {
  font-size: 1rem;
  line-height: 1;
}

.chart-toggle-btn .toggle-text {
  font-size: 0.85rem;
  white-space: nowrap;
}

/* Reset Controls */
.chart-reset-controls {
  display: flex;
  gap: 0.5rem;
}

.chart-reset-btn {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 8px 12px;
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  opacity: 0.8;
}

.chart-reset-btn:hover:not(:disabled) {
  background: rgba(255,107,107,0.2);
  border-color: #ff6b6b;
  opacity: 1;
}

.chart-reset-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.chart-container {
  background: rgba(255,255,255,0.03); backdrop-filter: blur(20px); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 24px; padding: 1.5rem; position: relative; overflow: hidden; min-height: 420px;
}
.chart-container::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: linear-gradient(90deg, #4ecdc4, #45b7d1, #ff6b6b); }

/* Responsive Chart Controls */
@media (max-width: 768px) {
  .chart-controls-row {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
    margin-bottom: 1rem;
  }
  
  .chart-filter-row {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }
  
  .chart-month-nav,
  .chart-view-controls,
  .chart-aggregation-toggle,
  .chart-reset-controls {
    justify-content: center;
  }
  
  .chart-view-controls {
    width: 100%;
  }
  
  .chart-view-btn {
    flex: 1;
  }
  
  .chart-aggregation-toggle {
    width: 100%;
  }
  
  .chart-toggle-btn {
    width: 100%;
    justify-content: center;
  }
  
  .chart-month-label {
    min-width: 100px;
  }
}

/* Sessions */
.sessions-section { margin-top: 2.5rem; }
.section-title { font-size: 1.6rem; font-weight: 600; margin-bottom: 1.2rem; text-align: center; opacity: 0.9; }

/* Empty Timeline State */
.empty-timeline {
  text-align: center;
  padding: 3rem 2rem;
  background: rgba(255,255,255,0.02);
  border: 2px dashed rgba(255,255,255,0.1);
  border-radius: 16px;
  margin: 1rem 0;
}
.empty-timeline-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}
.empty-timeline-message {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  opacity: 0.8;
}
.empty-timeline-subtitle {
  font-size: 0.9rem;
  opacity: 0.6;
  font-weight: 300;
}

.month-section { margin-bottom: 1.5rem; }
.month-header {
  background: rgba(255,255,255,0.05); backdrop-filter: blur(20px); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px; padding: 1rem 1.2rem; cursor: pointer; transition: all 0.3s ease; margin-bottom: 0.4rem;
  display: flex; justify-content: space-between; align-items: center;
}

/* Only apply hover effects on devices that support hover (desktop/mouse) */
@media (hover: hover) and (pointer: fine) {
  .month-header:hover { 
    background: rgba(255,255,255,0.08); 
    transform: translateY(-2px); 
  }
}
.month-title { font-size: 1.05rem; font-weight: 800; display: flex; gap: 0.9rem; align-items: center; }
.month-pl { font-weight: 800; }
.expand-icon { font-size: 1.1rem; transition: transform 0.25s ease; }
.month-header.expanded .expand-icon { transform: rotate(180deg); }

/* Casino P&L Header - Hidden on desktop, shown on mobile */
.casino-header {
  display: none; /* Hidden by default on desktop */
  grid-column: 1 / -1; /* Always start on new row */
}

/* Casino cards container stays as grid on desktop and always starts on new row */

/* Records Section - Collapsible on all devices */
.records-header {
  display: flex; /* Show on all devices */
  background: rgba(255,255,255,0.05); 
  backdrop-filter: blur(20px); 
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px; 
  padding: 1rem 1.2rem; 
  cursor: pointer; 
  transition: all 0.3s ease; 
  margin-bottom: 0.4rem;
  justify-content: space-between; 
  align-items: center;
  grid-column: 1 / -1; /* Span full width on desktop */
}

/* Only apply hover effects on devices that support hover */
@media (hover: hover) and (pointer: fine) {
  .records-header:hover { 
    background: rgba(255,255,255,0.08); 
    transform: translateY(-2px); 
  }
}

.records-title { 
  font-size: 1.05rem; 
  font-weight: 800; 
  text-align: left;
}

.records-header .expand-icon { 
  font-size: 1.1rem; 
  transition: transform 0.25s ease; 
}

.records-header.expanded .expand-icon { 
  transform: rotate(180deg); 
}

.records-cards {
  display: none; /* Hidden by default */
  animation: slideDown 0.2s ease;
}

.records-cards.expanded {
  display: contents; /* Show as grid children when expanded on desktop */
  grid-column: 1 / -1; /* Ensure it spans properly */
}

/* Extras Section - Collapsible on all devices */
.extras-header {
  display: flex; /* Show on all devices */
  background: rgba(255,255,255,0.05); 
  backdrop-filter: blur(20px); 
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px; 
  padding: 1rem 1.2rem; 
  cursor: pointer; 
  transition: all 0.3s ease; 
  margin-bottom: 0.4rem;
  justify-content: space-between; 
  align-items: center;
  grid-column: 1 / -1; /* Span full width on desktop */
}

/* Only apply hover effects on devices that support hover */
@media (hover: hover) and (pointer: fine) {
  .extras-header:hover { 
    background: rgba(255,255,255,0.08); 
    transform: translateY(-2px); 
  }
}

.extras-title { 
  font-size: 1.05rem; 
  font-weight: 800; 
  text-align: left;
}

.extras-header .expand-icon { 
  font-size: 1.1rem; 
  transition: transform 0.25s ease; 
}

.extras-header.expanded .expand-icon { 
  transform: rotate(180deg); 
}

.extras-cards {
  display: none; /* Hidden by default */
  animation: slideDown 0.2s ease;
}

.extras-cards.expanded {
  display: contents; /* Show as grid children when expanded on desktop */
  grid-column: 1 / -1; /* Ensure it spans properly */
}

.timeline { display: none; position: relative; padding: 1rem 0; animation: slideDown 0.2s ease; }
.timeline.expanded { display: block; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.timeline::before {
  content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; background: linear-gradient(180deg, #4ecdc4, #45b7d1, #ff6b6b);
  transform: translateX(-50%); z-index: 0;
}
.timeline-item { display: flex; margin-bottom: 1.6rem; position: relative; }
.timeline-item:nth-child(odd) { flex-direction: row-reverse; }
.timeline-content {
  flex: 1; max-width: calc(50% - 28px); width: calc(50% - 28px);
  background: rgba(255,255,255,0.05); backdrop-filter: blur(20px); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px; padding: 1rem; position: relative; z-index: 1;
}
.timeline-item:nth-child(odd) .timeline-content { margin-left: auto; }

/* Timeline dots — color-coded per entry type */
.timeline-dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(255,255,255,0.9);
  box-shadow: 0 0 12px rgba(255,255,255,0.25);
  z-index: 2;
}
.timeline-item.profit .timeline-dot {
  background: radial-gradient(circle at 30% 30%, #ffffff 30%, #25d6b8 80%);
  box-shadow: 0 0 12px rgba(37,214,184,0.55);
}
.timeline-item.loss .timeline-dot {
  background: radial-gradient(circle at 30% 30%, #ffffff 30%, #ff6b6b 80%);
  box-shadow: 0 0 12px rgba(255,107,107,0.55);
}
.timeline-item.withdrawal .timeline-dot {
  background: radial-gradient(circle at 30% 30%, #ffffff 30%, #ffd93d 80%);
  box-shadow: 0 0 12px rgba(255,217,61,0.55);
}

/* Card action buttons */
.card-actions { position: absolute; top: 8px; right: 8px; display: flex; gap: 6px; z-index: 5; }
.btn-edit { border-color: #4ecdc4; }
.btn-delete { border-color: #ff6b6b; }
.btn-move { border-color: #a78bfa; }

/* Inside a session card */
.session-date {
  font-size: 0.85rem; opacity: 0.75; margin-bottom: 0.35rem;
  text-transform: uppercase; letter-spacing: 0.08em;
}
.session-casino {
  font-size: 1.35rem; font-weight: 800; margin-bottom: 0.9rem; color: #4ecdc4;
}
.session-details {
  display: grid; grid-template-columns: repeat(2, minmax(140px, 1fr)); gap: 0.4rem 2rem;
  align-items: end; margin-bottom: 0.8rem;
}
.detail-item { text-align: center; }
.detail-label { font-size: 0.75rem; opacity: 0.6; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 0.2rem; }
.detail-value { font-size: 1.6rem; font-weight: 800; }

.session-pl {
  text-align: center; padding: 12px 16px; border-radius: 14px; font-size: 1.1rem; font-weight: 800; margin: 0.6rem 0 0.4rem;
}
.session-pl.positive { background: linear-gradient(135deg, rgba(78,205,196,0.22), rgba(78,205,196,0.06)); color: #4ecdc4; }
.session-pl.negative { background: linear-gradient(135deg, rgba(255,107,107,0.22), rgba(255,107,107,0.06)); color: #ff6b6b; }
.session-pl.neutral  { background: linear-gradient(135deg, rgba(255,217,61,0.22), rgba(255,217,61,0.06));  color: #ffd93d; }

.session-notes { margin-top: 0.2rem; font-size: 1rem; line-height: 1.45; }

/* Enhanced Color Coding */
.profit-indicator {
  display: inline-block;
  white-space: nowrap;
}



/* Enhanced Gradient Backgrounds for Amounts */
.amount-display {
  background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.05));
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 8px 12px;
  display: inline-block;
  font-weight: 700;
  transition: all 0.3s ease;
}

.amount-display.positive {
  background: linear-gradient(135deg, rgba(78,205,196,0.2), rgba(78,205,196,0.1));
  border-color: rgba(78,205,196,0.3);
  color: #4ecdc4;
}

.amount-display.negative {
  background: linear-gradient(135deg, rgba(255,107,107,0.2), rgba(255,107,107,0.1));
  border-color: rgba(255,107,107,0.3);
  color: #ff6b6b;
}

/* Enhanced Responsive Design */
.responsive-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

/* Mobile */
@media (max-width: 768px) {
/* Mobile-first sticky header banner design */
  :root { 
    --fab-size: 56px; 
    --header-height: 84px;
  }

  .header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(15, 15, 35, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding: 18px 16px;
    margin: 0;
    z-index: 100;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    height: var(--header-height);
  }

  .header h1 { 
    font-size: 1.8rem; 
    padding: 0;
    text-align: center;
    margin: 0;
    letter-spacing: -0.8px;
    line-height: 1.2;
    width: 100%;
  }

  /* Adjust mobile menu button for banner */
  .mobile-menu-btn {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.15);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 18px;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 101;
  }

  /* Add top padding to main content to account for fixed header */
  .container {
    padding-top: calc(var(--header-height) + 1rem);
    padding-bottom: calc(var(--fab-size) + 40px + env(safe-area-inset-bottom, 0));
  }

  /* Hide desktop header buttons; show hamburger */
  .header-actions { display: none !important; }
  .mobile-menu-btn { display: inline-flex; }
  .btn { padding: 8px 10px; font-size: 12px; }

  /* Adjust mobile menu for banner layout */
  .more-menu {
    position: fixed;
    top: calc(var(--header-height) + 4px);
    right: 16px;
    z-index: 150;
  }

  .stats-container { 
    grid-template-columns: 1fr; 
    gap: 1rem; 
    max-width: 100%;
  }
  
  .casino-cards-container {
    grid-column: 1 / -1;
    margin-top: 0;
  }

  /* Casino P&L Collapsible Header (Mobile Only) */
  .casino-header {
    display: flex; /* Show on mobile */
    background: rgba(255,255,255,0.05); 
    backdrop-filter: blur(20px); 
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 14px; 
    padding: 1rem 1.2rem; 
    cursor: pointer; 
    transition: all 0.3s ease; 
    margin-bottom: 0.4rem;
    justify-content: space-between; 
    align-items: center;
  }

  /* Only apply hover effects on devices that support hover */
  @media (hover: hover) and (pointer: fine) {
    .casino-header:hover { 
      background: rgba(255,255,255,0.08); 
      transform: translateY(-2px); 
    }
  }

  .casino-title { 
    font-size: 1.05rem; 
    font-weight: 800; 
    text-align: left;
  }

  .casino-header .expand-icon { 
    font-size: 1.1rem; 
    transition: transform 0.25s ease; 
  }

  .casino-header.expanded .expand-icon { 
    transform: rotate(180deg); 
  }

  /* Casino cards container on mobile */
  .casino-cards-container {
    display: none; /* Hidden by default on mobile */
    animation: slideDown 0.2s ease;
  }

  .casino-cards-container.expanded {
    display: grid; /* Show as grid when expanded */
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  /* Records cards on mobile */
  .records-cards.expanded {
    display: grid; /* Show as grid when expanded */
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  /* Extras cards on mobile */
  .extras-cards.expanded {
    display: grid; /* Show as grid when expanded */
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  /* Timeline becomes plain list on mobile */
  .timeline::before { display: none; }
  .timeline-dot { display: none; }
  .timeline-item { flex-direction: row !important; padding-left: 0 !important; }
  .timeline-content { max-width: 100%; }

  /* Card action buttons flow inside */
  .card-actions {
    position: static;
    justify-content: flex-end;
    margin-bottom: 6px;
    gap: 8px;
  }
  
  /* Ensure session details fit properly on small screens */
  .session-details {
    grid-template-columns: repeat(2, minmax(120px, 1fr)); 
    gap: 0.3rem 1rem;
    margin-bottom: 1rem;
  }
  
  /* Prevent long casino names from causing overflow */
  .session-casino {
    font-size: 1.2rem;
    line-height: 1.2;
    word-break: break-word;
    overflow-wrap: anywhere;
    margin-bottom: 1rem;
    padding-right: 8px; /* Add padding to prevent edge contact */
  }
  
  /* Adjust detail value font size to prevent overflow */
  .detail-value {
    font-size: 1.4rem;
    word-break: break-all;
    line-height: 1.1;
  }
  
  /* Improve session P&L display */
  .session-pl {
    margin: 0.8rem 0 0.6rem;
    padding: 10px 12px;
    font-size: 1rem;
    border-radius: 12px;
  }
  
  /* Better spacing for timeline items */
  .timeline-content {
    padding: 1.2rem;
    margin-bottom: 0.8rem;
  }
  
  /* Mobile Login Screen Fixes */
  .login-screen {
    padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
    min-height: 100vh;
    min-height: 100dvh; /* Use dynamic viewport height where supported */
  }
  
  .login-container {
    padding: 1rem;
    max-width: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: calc(100vh - env(safe-area-inset-top, 0) - env(safe-area-inset-bottom, 0));
    min-height: calc(100dvh - env(safe-area-inset-top, 0) - env(safe-area-inset-bottom, 0));
  }
  
  .login-header {
    margin-bottom: 2rem;
    margin-top: 1rem;
  }
  
  .login-header h1 {
    font-size: 2.2rem;
    letter-spacing: -1px;
    margin-bottom: 0.5rem;
  }
  
  .login-header p {
    font-size: 0.9rem;
  }
  
  .login-form-card {
    padding: 1.5rem;
    margin-bottom: 1rem;
  }
  
  .login-form-card h2 {
    font-size: 1.5rem;
  }
  
  .login-subtitle {
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
  }
  
  .login-btn {
    padding: 16px;
    font-size: 1.05rem;
    margin-bottom: 1rem;
  }
}

/* Very Small Mobile Screens (320px and below) */
@media (max-width: 320px) {
  .session-details {
    grid-template-columns: repeat(2, minmax(100px, 1fr)); 
    gap: 0.2rem 0.5rem;
  }
  
  .detail-value {
    font-size: 1.2rem;
  }
  
  .session-casino {
    font-size: 1.1rem;
  }
}

/* Color classes with higher specificity for stat values */
.stat-value.positive, .profit-indicator.positive { color: #4ecdc4 !important; }
.stat-value.negative, .profit-indicator.negative { color: #ff6b6b !important; }
.stat-value.neutral, .profit-indicator.neutral { color: #ffd93d !important; }

/* Fallback color classes for other elements */
.positive { color: #4ecdc4; }
.negative { color: #ff6b6b; }
.neutral  { color: #ffd93d; }

/* FAB */
.add-session-btn {
  position: fixed; width: var(--fab-size); height: var(--fab-size);
  background: linear-gradient(135deg, #4ecdc4, #45b7d1); border: none; border-radius: 50%;
  color: white; font-size: 2rem; cursor: pointer; box-shadow: 0 8px 25px rgba(78,205,196,0.4);
  transition: transform 0.3s ease, box-shadow 0.3s ease; z-index: 1000;
  bottom: calc(env(safe-area-inset-bottom, 0) + 24px);
  right: calc(env(safe-area-inset-right, 0) + 24px);
}

/* On mobile, ensure FAB doesn't overlap content */
@media (max-width: 768px) {
  .add-session-btn {
    bottom: calc(env(safe-area-inset-bottom, 0) + 20px);
    right: calc(env(safe-area-inset-right, 0) + 48px); /* Increased from 32px to 48px for even better clearance */
    width: calc(var(--fab-size) - 8px); /* Slightly smaller for better fit */
    height: calc(var(--fab-size) - 8px);
    font-size: 1.6rem;
  }
}
.add-session-btn:hover { transform: scale(1.1); box-shadow: 0 12px 35px rgba(78,205,196,0.6); }

/* Modals */
.modal { display: none; position: fixed; z-index: 2000; inset: 0; background: rgba(0,0,0,0.8); backdrop-filter: blur(5px); }
.modal-content {
  background: rgba(255,255,255,0.05); backdrop-filter: blur(20px); border: 1px solid rgba(255,255,255,0.1);
  margin: 2% auto; padding: 2rem; width: 90%; max-width: 600px; border-radius: 24px; position: relative;
  max-height: 95vh; overflow-y: auto; /* Prevent modal from exceeding screen height */
}
.close { color: #aaa; float: right; font-size: 28px; font-weight: bold; cursor: pointer; line-height: 1; }
.close:hover { color: #fff; }

.form-title { font-size: 1.6rem; margin-bottom: 1.5rem; text-align: center; font-weight: 600; }
.entry-type { display: flex; justify-content: center; gap: 1rem; margin-bottom: 1rem; }
.entry-type label {
  display: flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; padding: 10px 16px; border-radius: 10px;
  transition: background-color 0.3s; border: 2px solid rgba(255,255,255,0.1);
}
.entry-type label.active { background: rgba(78,205,196,0.2); border-color: #4ecdc4; }

/* Initially hidden form sections */
.form-grid.hidden { display: none; }
.form-grid.visible { display: grid; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.form-group { display: flex; flex-direction: column; }
.form-group label { font-weight: 600; margin-bottom: 6px; color: #fff; opacity: 0.9; }
.form-group input, .form-group textarea {
  padding: 10px 14px; border: 2px solid rgba(255,255,255,0.1); border-radius: 10px; font-size: 15px;
  background: rgba(255,255,255,0.05); color: #fff; transition: border-color 0.3s;
}
.form-group input:focus, .form-group textarea:focus {
  outline: none; border-color: #4ecdc4; box-shadow: 0 0 0 3px rgba(78,205,196,0.1);
}
.form-group textarea { resize: vertical; min-height: 42px; }

/* Tablet Design Enhancements */
@media (min-width: 769px) and (max-width: 1024px) {
  .stats-container {
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
  }
  
  .stat-card {
    padding: 1.5rem;
  }
  
  .timeline-content {
    padding: 1.5rem;
  }
  
  .session-details {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
  }
  
  .header h1 {
    font-size: 2.8rem;
  }
}

/* Large Screen Enhancements */
@media (min-width: 1025px) {
  .stats-container {
    grid-template-columns: repeat(4, 1fr);
  }

  /* Casino cards stay in their own grid container */
  .casino-cards-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
  }
  
  /* Enhanced hover effects for desktop */
  .timeline-content:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  }
  
  .stat-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
  }
}
