:root {
  /* Dark-space base with cooler neutral accents */
  --bg: #05060a;
  --bg-elevated: #0b0e14;
  --bg-elevated-soft: #0f1218;
  --accent: #4fb0ff; /* softer out-of-this-world blue */
  --accent-soft: rgba(79, 176, 255, 0.12);
  --accent-strong: #1e90ff;
  --accent-purple: #7c5cff;
  --accent-cyan: #2ad7f7;
  --text: #f3f6f9;
  --text-muted: #b6bdc6;
  --border-subtle: #2a3238;
  --danger: #ef4444;
  --warning: #fbbf24;
  --success: #22c55e;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow-x: hidden; /* prevent outer horizontal scrolling, vertical handled by .main */
}

/* ensure media like images never overflow their containers */
img,
video,
canvas {
  max-width: 100%;
  height: auto;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(56, 189, 248, 0.18), transparent 60%),
    radial-gradient(circle at bottom right, rgba(79, 70, 229, 0.16), transparent 65%),
    radial-gradient(circle at top, #020617 0, #000 55%);
  color: var(--text);
  min-height: 100vh;
  animation: bg-pan 30s linear infinite alternate;
}

.app-shell {
  /* sidebar fixed to left, main area scrolls separately */
  display: flex;
  min-height: 100vh;
  overflow: hidden; /* prevent double scrollbar */
}

.sidebar {
  background:
    radial-gradient(circle at top left, rgba(79, 176, 255, 0.12), transparent 70%),
    linear-gradient(180deg, #05060a 0%, #070812 40%, #05060a 100%);
  border-right: 1px solid #111827;
  padding: 1.5rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  /* use top/bottom instead of fixed 100vh so mobile browsers don't crop the bottom
     when the address bar expands/shrinks. allows the sidebar to stretch to the full
     available area and keeps the footer/profile visible. */
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: 240px;
  /* no scrolling on the sidebar itself; nav will scroll instead so footer can stay
     stuck to bottom of viewport */
  overflow: hidden;
  /* padding at bottom for devices with gesture bars/notch */
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
}

.logo {
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.9rem;
  color: var(--accent-strong);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  /* allow navigation area to scroll when it exceeds available space */
  flex: 1 1 auto;
  min-height: 0; /* enable flex item to shrink properly */
  overflow-y: auto;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  border-radius: 0.5rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  position: relative;
  overflow: hidden;
  transition:
    background 0.18s ease,
    color 0.18s ease,
    transform 0.12s ease,
    box-shadow 0.18s ease;
}

.nav-link:hover {
  background: radial-gradient(circle at left, rgba(37, 99, 235, 0.35), transparent 70%);
  color: var(--text);
  transform: translateX(2px);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.9);
}

.nav-link.active {
  background: radial-gradient(circle at top left, var(--accent-soft), transparent 60%);
  border: 1px solid rgba(148, 163, 184, 0.4);
  color: var(--text);
  box-shadow: 0 0 18px rgba(37, 99, 235, 0.55);
}

.main {
  padding: 1.25rem 1.5rem 1.5rem;
  margin-left: 240px;        /* make room for fixed sidebar */
  height: 100vh;
  overflow-y: auto;         /* page content scrolls here */
  -webkit-overflow-scrolling: touch; /* nice momentum on mobile */
  flex: 1 1 auto;            /* grow to fill remaining width */
  min-width: 0;             /* allow content to shrink inside flex container */
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.topbar-profile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  text-decoration: none;
  margin-left: 0.75rem;
}

.topbar-profile .avatar-small {
  width: 100%;
  height: 100%;
}

.topbar-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.content {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.grid {
  display: grid;
  gap: 1rem;
}

.grid-quick-stats {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.grid-two {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

/* on the My Account page we want each section to span full width rather than
   leaving an empty second column; override when wrapped in account-page */
.account-page .grid-two {
  grid-template-columns: 1fr;
}

.card {
  --card-radius: 0.9rem;
  --card-shadow: 0 14px 34px rgba(4, 6, 10, 0.8);
  --card-padding: 0; /* preserved by inner elements */

  min-width: 0; /* allow cards to shrink in grid layouts without wrapping */
  background:
    radial-gradient(circle at top left, rgba(79, 176, 255, 0.06), transparent 60%),
    radial-gradient(circle at bottom right, rgba(124, 92, 255, 0.04), transparent 60%),
    linear-gradient(145deg, rgba(10, 12, 16, 0.96), #070812);
  border-radius: var(--card-radius);
  border: 1px solid rgba(60, 70, 82, 0.55);
  box-shadow: var(--card-shadow);
  overflow: hidden;
  position: relative;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    border-color 0.2s ease;
  margin: 0.75rem 0; /* default vertical spacing when not in a grid */
}

.card::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: radial-gradient(circle at top, rgba(59, 130, 246, 0.35), transparent 60%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow:
    0 26px 55px rgba(15, 23, 42, 0.95),
    0 0 40px rgba(37, 99, 235, 0.3);
  border-color: rgba(59, 130, 246, 0.9);
}

.card:hover::before {
  opacity: 1;
}

.card-header {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(31, 41, 55, 0.9);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h2 {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

.card-body {
  padding: 1rem;
}

.stat-card {
  position: relative;
  overflow: hidden;
  padding: 1rem;
  border-radius: 0.9rem;
  box-shadow: 0 14px 34px rgba(4, 6, 10, 0.8);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 80px;
  text-align: center;
  margin: 0.75rem 0;
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top right, rgba(79, 176, 255, 0.12), transparent 65%);
  opacity: 0.45;
  pointer-events: none;
}

.stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
  white-space: nowrap;
  line-height: 1.2;
}

.stat-value {
  margin-top: 0.35rem;
  font-size: 1.7rem;
  font-weight: 700;
  white-space: nowrap;
}

/* value color signals */
.stat-value.value-positive {
  color: #22c55e; /* green */
}

.stat-value.value-negative {
  color: #ef4444; /* red */
}

.stat-value.value-neutral {
  color: var(--text); /* default */
}

.toolbar {
  display: flex;
  justify-content: flex-end;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  padding: 0.4rem 0.95rem;
  background: transparent;
  color: var(--text);
  font-size: 0.82rem;
  cursor: pointer;
  text-decoration: none;
  font-weight: 500;
  min-height: 2.2rem;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.07s ease, box-shadow 0.15s ease;
}

.btn:hover {
  background: rgba(148, 163, 184, 0.12);
  border-color: rgba(209, 213, 219, 0.9);
  transform: translateY(-1px);
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.9);
}

.btn-primary {
  background:
    linear-gradient(120deg, var(--accent) 0%, var(--accent-cyan) 40%, var(--accent-purple) 100%);
  border-color: transparent;
  box-shadow: 0 12px 30px rgba(37, 99, 235, 0.55);
}

.btn-primary:hover {
  filter: brightness(1.05);
}

.btn-secondary {
  background: rgba(15, 23, 42, 0.9);
}

.btn-ghost {
  border-color: rgba(75, 85, 99, 0.9);
}

.btn-danger {
  border-color: rgba(239, 68, 68, 0.85);
  color: #fecaca;
}

.btn-danger:hover {
  background: rgba(127, 29, 29, 0.5);
  box-shadow: 0 0 18px rgba(248, 113, 113, 0.5);
}

.btn-block {
  width: 100%;
}

.btn-small {
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
}

.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch; /* smooth momentum on iOS */
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
  /* keep cells on one line and ellipsis overflow */
  table-layout: fixed;
}

.table th,
.table td {
  padding: 0.45rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid rgba(31, 41, 55, 0.9);
  /* prevent wrapping and use ellipsis for overflow */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table th {
  font-weight: 500;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.table tr:last-child td {
  border-bottom: none;
}

/* highlight losses */
.table td.negative,
.summary-value.negative {
  color: var(--danger);
}

.clickable-row {
  cursor: pointer;
}

.clickable-row:hover {
  background: radial-gradient(circle at left, rgba(37, 99, 235, 0.18), transparent 60%);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  border: 1px solid rgba(148, 163, 184, 0.7);
  color: var(--text-muted);
}

.badge-type {
  border-color: rgba(56, 189, 248, 0.9);
  color: #7dd3fc;
}

.badge-status {
  border-color: rgba(59, 130, 246, 0.9);
  color: #dbeafe;
}

.badge-status-active {
  border-color: rgba(52, 211, 153, 0.7);
  color: #6ee7b7;
}

.badge-status-muted {
  border-color: rgba(75, 85, 99, 0.9);
  color: var(--text-muted);
}

.badge-muted {
  border-color: rgba(75, 85, 99, 0.9);
  color: var(--text-muted);
}

.badge-alert {
  border-color: rgba(248, 113, 113, 0.9);
  color: #fecaca;
  background: rgba(127, 29, 29, 0.4);
}

.status-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 999px;
  display: inline-block;
}

.status-active {
  background: var(--success);
}

.status-waiting_for_winners {
  background: var(--warning);
}

.status-won {
  background: var(--accent-strong);
}

.status-mint_live {
  background: #38bdf8;
}

.status-closed,
.status-dead {
  background: #4b5563;
}

.alert-panel {
  position: relative;
}

.alert-panel::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  border: 1px solid rgba(248, 113, 113, 0.35);
  opacity: 0.9;
  mix-blend-mode: screen;
  pointer-events: none;
  box-shadow: 0 0 25px rgba(248, 113, 113, 0.6);
}

.alert-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* Action Required panel styles */
.action-panel .urgency-group {
  margin-bottom: 0.75rem;
}
.urgency-high .badge-alert {
  background: rgba(255, 72, 66, 0.08);
  border-color: rgba(255, 72, 66, 0.9);
  color: #fecaca;
}
.urgency-high .alert-item { box-shadow: 0 6px 18px rgba(255, 72, 66, 0.06); }
.urgency-medium .badge-alert {
  background: rgba(255, 159, 67, 0.06);
  border-color: rgba(255, 159, 67, 0.9);
  color: #ffe4c2;
}
.urgency-medium .alert-item { box-shadow: 0 6px 16px rgba(255, 159, 67, 0.05); }
.urgency-low .badge-alert {
  background: rgba(34, 197, 94, 0.06);
  border-color: rgba(34, 197, 94, 0.9);
  color: #bbf7d0;
}
.urgency-low .alert-item { box-shadow: 0 6px 14px rgba(34, 197, 94, 0.04); }

.action-panel .alert-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.6rem;
  border-radius: 0.5rem;
  background: rgba(10,12,16,0.7);
}

.alert-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.4rem 0.5rem;
  border-radius: 0.5rem;
  background: rgba(15, 23, 42, 0.85);
  box-shadow: 0 0 18px rgba(248, 113, 113, 0.18);
}

.alert-text {
  font-size: 0.78rem;
}

.activity-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.activity-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
}

.activity-meta {
  color: var(--text-muted);
  font-size: 0.72rem;
}

.muted {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.small {
  font-size: 0.75rem;
}

.flash-container {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.flash {
  padding: 0.4rem 0.6rem;
  border-radius: 0.4rem;
  font-size: 0.8rem;
}

.flash-success {
  background: rgba(22, 163, 74, 0.2);
  border: 1px solid rgba(22, 163, 74, 0.5);
}

.flash-error {
  background: rgba(220, 38, 38, 0.25);
  border: 1px solid rgba(220, 38, 38, 0.5);
  font-weight: 500;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem; /* consistent vertical spacing between fields */
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.6rem 0.75rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.form-group.full {
  grid-column: 1 / -1;
}

.form-group label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
}

.section-divider span {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-muted);
  border-bottom: 1px solid rgba(31, 41, 55, 0.9);
  padding-bottom: 0.2rem;
}

input[type="text"],
input[type="url"],
input[type="number"],
textarea,
select {
  background: rgba(15, 23, 42, 0.9);
  border-radius: 0.5rem;
  border: 1px solid rgba(31, 41, 55, 0.9);
  padding: 0.35rem 0.5rem;
  color: var(--text);
  font-size: 0.82rem;
  width: 100%;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(124, 58, 237, 0.5);
}

textarea {
  resize: vertical;
}

.form-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.3rem;
}

.form-actions.full {
  grid-column: 1 / -1;
}

.accounts-select {
  display: flex;
  flex-direction: column;
  max-height: 320px;
  overflow-y: auto;
  gap: 0.3rem;
}

.account-checkbox {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
}

.account-checkbox input[type="checkbox"] {
  width: 0.8rem;
  height: 0.8rem;
}

.account-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}

.account-card {
  background:
    linear-gradient(180deg, rgba(12,14,18,0.9), rgba(18,20,24,0.9));
  border-radius: 0.9rem;
  border: 1px solid rgba(40, 46, 52, 0.85);
  padding: 1rem;
  box-shadow: 0 14px 34px rgba(4, 6, 10, 0.8);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin: 0.75rem 0;
}

.account-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.account-card-meta-wrap {
  min-width: 0;
  overflow: hidden;
}

.account-name {
  font-size: 0.9rem;
  font-weight: 600;
}

.account-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.account-meta-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  max-width: 100%;
  margin-top: 0.15rem;
}

.account-meta-truncate .account-wallet {
  display: inline;
}

.account-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.25rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(31, 41, 55, 0.6);
}

.participation-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.participation-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  min-width: 4.5rem;
}

.participation-row select {
  flex: 1;
  min-width: 0;
  max-width: 100%;
}

.override-form {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.override-form label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
}

.override-form select {
  max-width: 180px;
}

/* inputs should not wrap their contents */
input[type="text"],
input[type="url"],
input[type="number"],
input[type="datetime-local"],
select,
textarea {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toolbar,
.topbar {
  position: relative;
  z-index: 5;
}

/* Analytics & Summary Stat Cards */
.summary-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid rgba(31, 41, 55, 0.5);
}

.summary-stat:last-child {
  border-bottom: none;
}

.summary-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.summary-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-breakdown {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  opacity: 0.85;
}

/* background animation */
@keyframes bg-pan {
  0% {
    background-position: 0% 0%, 100% 100%, 50% 0%;
  }
  50% {
    background-position: 50% 50%, 50% 100%, 50% 20%;
  }
  100% {
    background-position: 100% 0%, 0% 100%, 50% 40%;
  }
}

/* utility */
.hidden {
  display: none !important;
}

.summary-results {
  margin-top: 1rem;
}

/* form-specific helpers */
.form-error {
  color: var(--danger);
  font-size: 0.75rem;
  margin-top: 0.25rem;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.topbar-username {
  font-size: 0.85rem;
  color: var(--text);
  white-space: nowrap;
}

/* sidebar footer showing current user info */
.sidebar-footer {
  margin-top: auto;
  padding: 1rem 0;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);

  /* keep footer visible even when sidebar scrolls */
  position: sticky;
  bottom: 0;
  background: inherit; /* match sidebar background */
  z-index: 2;
}

/* slightly larger avatar in sidebar */
.sidebar-footer .avatar-small {
  width: 32px;
  height: 32px;
}

.sidebar-username {
  white-space: nowrap;
}

.sidebar-footer a {
  color: var(--text-muted);
  text-decoration: none;
}

.avatar-small {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--border-subtle);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  font-size: 0.85rem;
}

.avatar-placeholder {
  background: var(--accent-soft);
}
.hidden {
  display: none !important;
}

/* ensure grid gap controls spacing rather than individual card margins */
.grid > .card,
.grid > .stat-card,
.grid > .account-card {
  margin: 0;
}

@media (max-width: 800px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
  }
  .nav {
    flex-direction: row;
  }
  .main {
    padding: 1rem;
  }
}

/* collapse sidebar entirely on very narrow screens to maximise real estate */
@media (max-width: 600px) {
  /* keep sidebar in DOM but slide it off-screen by default */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: min(80%, 240px);
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    display: flex;
    flex-direction: column;
    background:
      radial-gradient(circle at top left, rgba(79, 176, 255, 0.12), transparent 70%),
      linear-gradient(180deg, #05060a 0%, #070812 40%, #05060a 100%);
    z-index: 1000;
  }
  .main {
    margin-left: 0 !important;
  }
  .show-sidebar .sidebar {
    transform: translateX(0);
  }
  /* nav inside mobile drawer should be vertical */
  .nav {
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem 0;
  }
  /* backdrop when menu open */
  .show-sidebar::after {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 900;
  }
  /* restore vertical menu items inside the drawer */
  .nav {
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem 0;
  }
  /* optional backdrop to dim content when menu is open */
  .show-sidebar::after {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 900;
  }
}

