:root {
  --bg-main: #0d1117;
  --bg-card: #161b22;
  --bg-card-hover: #1c2128;
  --bg-row-alt: rgba(255, 255, 255, 0.02);
  --border-color: #30363d;
  --border-accent: #388bfd;
  --text-main: #f0f6fc;
  --text-muted: #8b949e;
  --text-dim: #6e7681;
  --color-green: #3fb950;
  --color-green-bg: rgba(63, 185, 80, 0.15);
  --color-red: #f85149;
  --color-red-bg: rgba(248, 81, 73, 0.15);
  --color-gold: #e3b341;
  --color-purple: #bc8cff;
  --color-blue: #58a6ff;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
}

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

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-family);
  min-height: 100vh;
  padding: 24px 16px;
  line-height: 1.5;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
}

header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ==========================================================================
   Animations & Transitions
   ========================================================================== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes floatGem {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
    box-shadow: 0 0 15px rgba(213, 63, 140, 0.35);
  }
  50% {
    transform: translateY(-4px) rotate(2deg);
    box-shadow: 0 0 25px rgba(213, 63, 140, 0.6);
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes flashHighlight {
  0% {
    background-color: rgba(56, 139, 253, 0.35);
  }
  100% {
    background-color: transparent;
  }
}

@keyframes profitGlow {
  0%, 100% {
    box-shadow: 0 0 8px rgba(63, 185, 80, 0.2);
  }
  50% {
    box-shadow: 0 0 16px rgba(63, 185, 80, 0.45);
  }
}

@keyframes skeletonPulse {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.brand-icon {
  font-size: 2rem;
  background: rgba(213, 63, 140, 0.15);
  border: 1px solid rgba(213, 63, 140, 0.3);
  padding: 6px 12px;
  border-radius: 12px;
  display: inline-block;
  animation: floatGem 4s ease-in-out infinite;
  transition: transform 0.3s ease;
}

.brand-icon:hover {
  transform: scale(1.1) rotate(6deg);
}

.brand h1 {
  font-size: 1.6rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.5px;
}

.brand p {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.status-dot {
  width: 9px;
  height: 9px;
  background: var(--color-green);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--color-green);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.btn-refresh {
  background: #238636;
  color: #fff;
  border: 1px solid rgba(240, 246, 252, 0.1);
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-refresh:hover {
  background: #2ea043;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(35, 134, 54, 0.35);
}

.btn-refresh:active {
  transform: translateY(0);
}

.btn-refresh:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-refresh.loading span,
.btn-refresh:disabled span {
  display: inline-block;
  animation: spin 0.8s linear infinite;
}

.alert-box {
  background: var(--color-red-bg);
  border: 1px solid var(--color-red);
  color: #ff7b72;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 20px;
  display: none;
}

/* ==========================================================================
   Forge Slots Configuration Bar
   ========================================================================== */
.forge-slots-bar {
  background: linear-gradient(135deg, rgba(22, 27, 34, 0.9) 0%, rgba(33, 38, 45, 0.75) 100%);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--color-purple);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 24px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  animation: fadeIn 0.4s ease both;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.forge-slots-bar:hover {
  border-color: rgba(188, 140, 255, 0.4);
  box-shadow: 0 6px 24px rgba(188, 140, 255, 0.12);
}

.forge-slots-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.forge-slots-title-group {
  display: flex;
  align-items: center;
  gap: 14px;
}

.forge-icon {
  font-size: 1.5rem;
  background: rgba(188, 140, 255, 0.15);
  border: 1px solid rgba(188, 140, 255, 0.3);
  padding: 8px 12px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.forge-label-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.forge-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
}

.forge-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.storage-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  color: #3fb950;
  background: rgba(63, 185, 80, 0.12);
  border: 1px solid rgba(63, 185, 80, 0.25);
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
  transition: all 0.3s ease;
}

.storage-badge.saved-animate {
  animation: flashHighlight 0.6s ease;
  background: rgba(63, 185, 80, 0.25);
  border-color: #3fb950;
  color: #7ee787;
}

.forge-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.forge-input-group {
  display: flex;
  align-items: center;
  background: #0d1117;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

.btn-forge-stepper {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  border: none;
  width: 36px;
  height: 36px;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  user-select: none;
}

.btn-forge-stepper:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.btn-forge-stepper:active {
  background: rgba(255, 255, 255, 0.2);
}

.forge-slots-input {
  width: 48px;
  height: 36px;
  background: transparent;
  border: none;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: #58a6ff;
  outline: none;
  -moz-appearance: textfield;
}

.forge-slots-input::-webkit-inner-spin-button,
.forge-slots-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.forge-presets {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.preset-label {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-weight: 600;
  margin-right: 2px;
}

.btn-preset {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-preset:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-color: var(--text-dim);
}

.btn-preset.active {
  background: rgba(188, 140, 255, 0.25);
  border-color: var(--color-purple);
  color: #e2caff;
  font-weight: 700;
  box-shadow: 0 0 10px rgba(188, 140, 255, 0.35);
}

.dashboard-rows {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.tracker-row-section {
  background: rgba(22, 27, 34, 0.4);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 20px;
  animation: fadeIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
  transition: border-color 0.25s ease;
}

.row-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(240, 246, 252, 0.1);
}

.row-badge-tag {
  font-size: 0.75rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  transition: transform 0.2s ease;
}

.row-badge-tag:hover {
  transform: scale(1.05);
}

.tag-buy {
  background: rgba(56, 139, 253, 0.2);
  color: #58a6ff;
  border: 1px solid rgba(56, 139, 253, 0.4);
}

.tag-sell {
  background: rgba(227, 179, 65, 0.2);
  color: #e3b341;
  border: 1px solid rgba(227, 179, 65, 0.4);
}

.row-title-container {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.row-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.code-badge {
  font-size: 0.8rem;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 8px;
  border-radius: 4px;
  color: #79c0ff;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.row-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
  gap: 24px;
}

@media (max-width: 600px) {
  .cards-grid {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.25s ease, box-shadow 0.25s ease;
  animation: fadeIn 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.card:hover {
  transform: translateY(-4px);
  border-color: rgba(88, 166, 255, 0.6);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4), 0 0 16px rgba(88, 166, 255, 0.15);
}

.card.flash-update {
  animation: flashHighlight 1.2s ease-out;
}

.card-header {
  padding: 18px 20px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-multiplier {
  background: #1f6feb;
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 2px 8px;
  border-radius: 6px;
  transition: transform 0.2s ease;
}

.card:hover .card-multiplier {
  transform: scale(1.06);
}

.card-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: #fff;
}

.card-body {
  padding: 20px;
  flex: 1;
}

.table-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  font-weight: 700;
  margin-bottom: 10px;
}

.items-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
  font-size: 0.9rem;
}

.items-table th {
  text-align: left;
  padding: 8px 10px;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
}

.items-table th.text-right {
  text-align: right;
}

.items-table tr {
  transition: background-color 0.2s ease;
}

.items-table td {
  padding: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: color 0.2s ease;
}

.items-table tr:hover {
  background-color: var(--bg-row-alt);
}

.items-table tr:hover .item-icon {
  transform: scale(1.2) rotate(4deg);
}

.item-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.item-icon {
  font-size: 1.2rem;
  display: inline-block;
  transition: transform 0.2s ease;
}

.item-name {
  font-weight: 600;
}

.item-qty {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.06);
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
  transition: background-color 0.2s ease;
}

.items-table tr:hover .item-qty {
  background: rgba(255, 255, 255, 0.12);
}

.text-right {
  text-align: right;
}

.summary-section {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

.card:hover .summary-section {
  border-color: rgba(255, 255, 255, 0.15);
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.95rem;
}

.summary-label {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.summary-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition: transform 0.2s ease;
}

.profit-row {
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
  font-size: 1.05rem;
}

.profit-badge {
  font-size: 1.15rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.profit-badge:hover {
  transform: scale(1.04);
}

.profit-positive {
  color: var(--color-green);
  background: var(--color-green-bg);
  box-shadow: 0 0 10px rgba(63, 185, 80, 0.15);
  animation: profitGlow 3s ease-in-out infinite;
}

.profit-negative {
  color: var(--color-red);
  background: var(--color-red-bg);
  box-shadow: 0 0 10px rgba(248, 81, 73, 0.15);
}

.margin-tag {
  font-size: 0.8rem;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
  font-weight: 600;
}

footer {
  margin-top: 32px;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.8rem;
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
}
