* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: sans-serif;
}

html,
body {
  background: linear-gradient(#141638, #0d1026);
  color: white;
}
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#header,
#navbar,
#footer {
  flex-shrink: 0;
}

.table-wrapper {
  flex: 1;
  overflow-y: auto;
}

:root {
  --z-dropdown: 100;
  --z-overlay: 200;
  --z-popup: 300;
  --z-modal: 400;
}

/* ===== GLOBAL LINKS STYLE ===== */
a {
  color: #ffffff; /* Pixel blue */
  text-decoration: none;
  font-weight: 700;
  transition: 0.15s ease;
  height: 100%;
}
.header {
  position: relative;
  z-index: 200000;
  overflow: visible;
}
.profile-dropdown {
  z-index: var(--z-popup);
}

/* ===== Header ===== */
.header {
  background: linear-gradient(
    to top,
    rgba(11, 20, 34, 0.85),
    rgba(11, 20, 34, 0.45)
  ) !important;

  backdrop-filter: blur(10px);

  border-top: 1px solid rgba(60, 90, 255, 0.35);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.45);

  color: #9fb4e0 !important;

  padding: 6px 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 17px;
}
.header {
  position: relative;
}
.logo {
  margin-left: 20px;
}
.market-box {
  margin-right: auto;
}

.market-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

.market:hover {
  box-shadow: 0 0 15px red;
}
.market:active {
  transform: scale(0.95);
}

.logo {
  width: 65px;
  height: 65px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.pic-logo {
  width: 100%;
  height: 100%;
  object-fit: cover; /* مهم‌ترین خط */
  display: block;
}

/* Sidebar */

.menu-toggle {
  width: 42px;
  height: 42px;
  background: orange;
  border-radius: 10px;
  cursor: pointer;
}
.menu-toggle {
  position: relative;
  z-index: var(--z-popup);
}

.side-menu {
  position: fixed !important;
  top: 0;
  right: -320px; /* مخفی */
  width: 300px;
  height: 100vh;
  background: #0f172a;
  transition: right 0.3s ease;
  z-index: 999999 !important;
  overflow-y: auto;
}

.side-menu.active {
  right: 0 !important;
}

/* Overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  z-index: 999998;
}

.overlay.active {
  opacity: 1;
  pointer-events: all;
}

.side-menu .side-item:hover {
  background: #2f46ff;
}

.menu-toggle:hover {
  box-shadow: 0 0 15px red;
}
.menu-toggle:active {
  transform: scale(0.95);
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
}

.side-item {
  display: flex;
  align-items: center;
  gap: 12px;

  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;

  background: #1a1a1a;
  color: #fff;

  transition: background 0.2s ease;
}
.icon-box {
  width: 42px;
  height: 42px;
  background: #222;
  border-radius: 10px;

  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-box img {
  width: 28px;
  height: auto;
}
/* .side-item:active,
.side-item:focus {
  background: #1e6cff; }*/

.side-item:hover {
  background: #2f46ff;
}
.side-menu::-webkit-scrollbar {
  scrollbar-width: thin;
  scrollbar-color: #1e6cff #121212;
}

a {
  text-decoration: none;
}
/* ===== Nav ===== */
.horizontal-nav {
  display: flex;
  align-items: flex-start; /* ⭐ مهم */
  position: relative;
  gap: 12px;
  padding: 5px 7px;
  background: #0f172a;
  width: 100%;
  box-sizing: border-box;
}

.nav-item > a,
.skill-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 1px 1px;
  white-space: nowrap;
  width: 100%;
  justify-content: center;
}

.horizontal-nav .nav-item {
  flex: 1 1 max-content; /* ⭐ جادو اینجاست */
  min-width: max-content; /* کوچیک‌تر از متن و آیکن نشه */
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 5px 7px;
  border-radius: 12px;
  background: #1e293b;
  white-space: nowrap;
  transition:
    background 0.2s ease,
    transform 0.2s ease;
  min-width: 0; /* ⭐ خیلی مهم */
  cursor: pointer;
  min-height: 40px;
}

.nav-item > a {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: inherit;
}

.nav-icon img {
  width: 26px;
  height: 26px;
  object-fit: contain;
}

.horizontal-nav span {
  font-family: "Pixelify Sans", sans-serif;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.horizontal-nav .nav-item:hover {
  background: #2f46ff;
  transform: translateY(-2px);
}

/* آیکن */
.nav-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
}

/* متن */

/* ===== Main ===== */
.container {
  flex: 1;
  padding: 5px 5px;
  margin-top: 5px;
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* هاور برای cart ها در صحفه اصلی */
.card {
  cursor: pointer;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.card:hover {
  transform: translateY(-4px);
}

/* .card.active {
  background: linear-gradient(135deg, #2f46ff, #1fa2ff);
  box-shadow: 0 0 20px rgba(47,70,255,0.9);
} */

.row {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 25px;
  flex-wrap: wrap;
}

/* ===== Cards ===== */
.card {
  width: 220px;
  height: 100px;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  text-align: center;
  color: white;
}

.card span {
  font-size: 25px;
  font-weight: bold;
  /* font-family: 'Press Start 2P', cursive; */
  /* font-family: 'VT323', monospace; */
  font-family: "Pixelify Sans", sans-serif;
}

.icons {
  gap: 8px; /* فاصله بین آیکن‌ها */
  align-items: center;
  justify-content: center;
}

.icon {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  /* background-color: #2d46ff; */
}

.card-icons {
  display: flex;
  flex-direction: row;
  justify-content: center; /* وسط */
  align-items: center;
  gap: 6px;
  flex-wrap: wrap; /* اگر زیاد شد بشکنه */
}
.card:hover {
  box-shadow: 0 0 15px rgba(47, 70, 255, 0.8);
}
.card:active {
  transform: scale(0.95);
}

.card {
  background: linear-gradient(135deg, #2f46ff, #355cff);
  border-radius: 18px;
  padding: 14px;
}
.tools-icon {
  width: 30px;
  height: 30px;
}
.text-row-cyan {
  margin-top: 10px;
}
.card.large .icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  margin-bottom: 6px;
}

.card.large .icon img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.card.large {
  background: linear-gradient(135deg, #ff9800, #ffcc00);
  box-shadow: 0 0 20px rgba(255, 165, 0, 0.6);
}

/* Colors */
.blue .card {
  background: #2d46ff;
}
.red .card {
  background: #6c757d;
}
.gold .card {
  background: #1e8449;
}
.cyan .card {
  background: orange;
}

/* ===== Footer ===== */
.footer {
  background: linear-gradient(
    to top,
    rgba(11, 20, 34, 0.85),
    rgba(11, 20, 34, 0.45)
  ) !important;

  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);

  border-top: 1px solid rgba(60, 90, 255, 0.35);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.45);

  color: #9fb4e0 !important;

  padding: 18px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 2px solid rgba(255, 255, 255, 0.1);
}

/* ===== Left Side ===== */
.footer-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.footer-logo {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.footer-text {
  font-size: 14px;
  color: #ddd;
  font-family: "Pixelify Sans", sans-serif;
}

/* ===== Right Icons ===== */
.footer-right {
  display: flex;
  gap: 12px;
}

.social {
  width: 36px;
  height: 36px;
  background: #1e293b;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.2s;
}

.social img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

/* Hover game style */
.social:hover {
  background: #2f46ff;
  transform: scale(1.1);
  box-shadow: 0 0 10px rgba(47, 70, 255, 0.7);
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .card {
    width: 100%;
    max-width: 320px;
  }

  .large {
    width: 100%;
  }

  .footer {
    flex-direction: column;
    gap: 10px;
  }
}

.table-wrapper {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;

  background: #0b1220;
  padding: 10px;
  border-radius: 14px;
}

.pixel-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  color: white;
}

.pixel-table th {
  background: #1f2937;
  padding: 10px;
  border: 1px solid #2f3b4a;
  text-align: center;
  font-weight: 600;
}

.pixel-table td {
  padding: 8px;
  border: 1px solid #1f2937;
  text-align: center;
}

.pixel-table tbody tr:nth-child(even) {
  background: #0f172a;
}

.pixel-table tbody tr:hover {
  background: rgba(47, 70, 255, 0.2);
}

.skill-icon {
  width: 24px;
  height: 24px;
}
/* شروع صحفه  calcuations */

.calc-container {
  padding: 20px;
  color: white;
}

h1 {
  font-size: 26px;
}

/* Input Panel */
.calc-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  background: #0f172a;
  padding: 15px;
  margin-bottom: 20px;
}

.calc-input {
  display: flex;
  flex-direction: column;
  min-width: 150px;
}

.calc-input label {
  font-size: 12px;
  opacity: 0.7;
}

.calc-input input {
  background: #111827;
  border: none;
  color: white;
  padding: 8px;
  border-radius: 6px;
}

.calc-btn {
  background: #2f46ff;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  color: white;
  font-weight: bold;
}

/* Summary Cards */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.summary-card {
  background: #111827;
  padding: 15px;
  border-radius: 12px;
  border: 1px solid #1f2937;
}

.summary-card span {
  font-size: 12px;
  opacity: 0.7;
}

.summary-card h2 {
  font-size: 20px;
  margin-top: 5px;
}

.summary-card.recommend {
  border: 2px solid #22c55e;
  background: rgba(34, 197, 94, 0.15);
}

/* Decision Table */
.decision-table {
  width: 100%;
  border-collapse: collapse;
  background: #0f172a;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 15px;
}

.decision-table th,
.decision-table td {
  padding: 10px;
  border-bottom: 1px solid #1f2937;
}

.decision-table th {
  background: #1f2937;
}

.craft {
  color: #22c55e;
  font-weight: bold;
}

.buy {
  color: #ef4444;
  font-weight: bold;
}

/* Breakdown */
.breakdown-btn {
  background: transparent;
  border: 1px solid #2f46ff;
  color: #2f46ff;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.craft-tree {
  background: #0b1220;
  padding: 10px;
  border-radius: 10px;
  margin-top: 10px;
  font-family: monospace;
}

/* Modal background */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

/* Box */
.modal-box {
  background: #0f172a;
  color: white;
  padding: 20px;
  border-radius: 14px;
  min-width: 400px;
  max-width: 500px;
  min-height: 300px;
  max-height: 400px;
  border: 1px solid #2f46ff;
  box-shadow: 0 0 20px rgba(47, 70, 255, 0.4);
}

.modal-box h3 {
  margin-bottom: 10px;
}

.modal-box ul {
  margin: 10px 0;
  padding-left: 15px;
}

.modal-box li {
  margin-bottom: 6px;
}

.close-btn {
  background: #2f46ff;
  border: none;
  padding: 8px 12px;
  border-radius: 6px;
  color: white;
  cursor: pointer;
}

/* Used In button */
.usedin-btn {
  background: transparent;
  border: 1px solid #2f46ff;
  color: #2f46ff;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 15px;
}
#usedinList li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.usedin-icon {
  width: 18px;
  height: 18px;
}
/* مخصوص فایل market */

.market-search-bar {
  width: 100%;
  max-width: 100%;
  margin: 10px 0;
}

/* متن placeholder هم بزرگ و بولد */
#searchBox::placeholder {
  font-size: 16px;
  font-weight: 600;
  color: #6b7280;
}

/* فوکوس حرفه‌ای */
#searchBox:focus {
  border-color: #22c55e;
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.5);
}

#pagination {
  margin-top: 15px;
  text-align: center;
}

#pagination button {
  padding: 6px 12px;
  margin: 2px;
  background: #0f172a;
  border: 1px solid #2f46ff;
  color: white;
  cursor: pointer;
  font-size: 13px;
  transition: 0.15s;
}

#pagination button:hover {
  background: #2f46ff;
}

#pagination button.active {
  background: #22c55e;
  color: black;
  border-color: #22c55e;
}

#pagination button:hover {
  background: #444;
}
@media (max-width: 768px) {
  #pagination button {
    padding: 4px 8px;
    font-size: 11px;
  }
}

/* ===== Desktop Default ===== */
.pixel-table td,
.pixel-table th {
  font-size: 13px;
  white-space: nowrap;
}

/* ===== Tablet ===== */
@media (max-width: 1024px) {
  .pixel-table td,
  .pixel-table th {
    font-size: 12px;
  }

  .pixel-table .icon {
    width: 20px;
    height: 20px;
  }
}

/* ===== Mobile ===== */
@media (max-width: 768px) {
  .pixel-table td,
  .pixel-table th {
    font-size: 11px;
  }

  /* اجازه wrap اسم */
  .pixel-table .item-name {
    white-space: normal;
  }
}

/* ===== Small Mobile ===== */
@media (max-width: 480px) {
  /* فونت کوچکتر */
  .pixel-table td,
  .pixel-table th {
    font-size: 10px;
  }
}
@media (max-width: 480px) {
  .price-cell {
    gap: 2px;
  }

  .price-cell img.ui-icon {
    width: 12px;
    height: 12px;
  }
}

/* ===== Market Search ===== */
.market-search-bar {
  width: 100%;
  margin-bottom: 12px;
}

/* ===== Table Wrapper ===== */
.table-wrapper {
  overflow-x: hidden;
}

/* ===== Pixel Table ===== */
.pixel-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  color: white;
}

.pixel-table tbody tr:nth-child(even) {
  background: #0f172a;
}

.pixel-table tbody tr:hover {
  background: rgba(47, 70, 255, 0.2);
}

/* Icon */
.pixel-table .icon {
  width: 32px;
  height: 32px;
}

/* Name */
.pixel-table .item-name {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Responsive ===== */
/* Tablet */
@media (max-width: 1024px) {
  .pixel-table td,
  .pixel-table th {
    font-size: 12px;
  }
}

/* Mobile */
@media (max-width: 768px) {
  .pixel-table td,
  .pixel-table th {
    font-size: 12px; /* ثابت نگه می‌داریم */
  }

  .pixel-table .item-name {
    white-space: normal;
  }
}

/* Pixel Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #020617;
}

::-webkit-scrollbar-thumb {
  background: #2f46ff;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: #22c55e;
}

/* جدولهای صفحات */

.pixel-table thead th {
  position: sticky;
  top: 0;
  background: #020617;
  z-index: 10;
}

/* اسم wrap */
.pixel-table .item-name {
  white-space: normal;
}

/* ===== GLOBAL ITEM POPUP (DATA CENTER) ===== */

#popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999999;
}

#popup-overlay.hidden {
  display: none;
}

.popup {
  width: 85%;
  max-width: 1100px;
  height: 80%;
  background: #0b1220;
  border: 2px solid #2f46ff;
  border-radius: 18px;
  box-shadow: 0 0 40px rgba(47, 70, 255, 0.6);
  position: relative;
  padding: 24px;
  overflow: auto;
}

/* Close button بالا سمت راست */
.popup .close-btn {
  position: absolute;
  top: 14px;
  right: 18px;
  background: transparent;
  border: none;
  font-size: 22px;
  color: #ff4d4d;
  cursor: pointer;
}

/* Header */
#popup-title {
  text-align: center;
  font-size: 22px;
  font-weight: bold;
  color: #ffffff;
  border-bottom: 1px solid #1f2937;
  padding-bottom: 8px;
}

/* Content area */
#popup-content {
  height: calc(100% - 70px);
  border-radius: 12px;
  background: #0f172a;
  border: 1px solid #1f2937;
}

/* تنظیم ایکون های کارت ها در صحفه اصلی */

.icon img {
  max-width: 30px;
  max-height: 30px;
  object-fit: contain;
}
/* ===== MARKETS FINAL LAYOUT ===== */

/* حالت عادی (لپ‌تاپ و کوچیک‌تر) */
.market-a .table-wrapper,
.market-b .table-wrapper {
  width: 96%;
  margin: 20px auto;
  overflow-y: auto;
}

/* فقط مانیتورهای بزرگ */
@media (min-width: 1600px) {
  .market-a .table-wrapper,
  .market-b .table-wrapper {
    width: 70%;
  }
}

.pixel-table th:nth-child(2),
.pixel-table td:nth-child(2),
.pixel-table th:nth-child(3),
.pixel-table td:nth-child(3) {
  text-align: left;
  padding-left: 16px;
}
.pixel-table th:nth-child(3),
.pixel-table td:nth-child(3) {
  width: 400px;
}
/* ستون icon باریک‌تر */
.pixel-table th:nth-child(1),
.pixel-table td:nth-child(1) {
  width: 85px;
  text-align: center;
}
/* cursor pointer روی icon های جدول */
/* pointer روی اسم آیتم */
.pixel-table .item-name {
  cursor: pointer;
}

/* جدول صفحات ایتم ها */

/* ===== FORCE TABLE GRID LINES ===== */
/* ===== Make skill tables look like market table ===== */

#itemsTable {
  width: 100%;
  border-collapse: collapse;
}

#itemsTable thead th {
  background: linear-gradient(to bottom, #0f1b2d, #0b1422);
  padding: 10px;
  text-align: center;
}

#itemsTable tbody td {
  padding: 8px;
  text-align: center;
}
.market-search {
  width: 100%;
  padding: 12px;
  margin-bottom: 12px;
  background: #0b1422;
  border: 1px solid #2f3b4a;
  color: white;
  font-size: 14px;
  outline: none;
}

.market-search::placeholder {
  color: #6b7a99;
}
.table-wrapper {
  overflow-y: auto;
  overflow-x: auto;
}

/* هدر جدول ثابت بمونه */
.table-wrapper thead th {
  position: sticky;
  top: 0;
  z-index: 5;
}

/* ===== SKILL DROPDOWN ===== */

.nav-item.dropdown {
  position: relative;
}

/* منو */
.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 100%;
  background: #0b1220;
  border: 1px solid #2f46ff;
  border-radius: 12px;
  padding: 8px;
  flex-direction: column;
  gap: 6px;
  z-index: 99999;
}

.nav-item.dropdown.open .dropdown-menu {
  display: flex;
}

/* وقتی بازه */
.nav-item.dropdown.open .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-menu a:hover {
  background: #2f46ff;
}

.dropdown-menu img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.horizontal-nav {
  position: relative;
  z-index: 100000;
}

.dropdown-menu a {
  position: relative;
  overflow: visible; /* ⭐ اجازه بده آیکن بیرون بزنه */
}

.dropdown-menu a img {
  width: 24px; /* بزرگ‌تر از قبل */
  height: 24px;
  object-fit: contain;

  margin-top: -4px; /* ⭐ از باکس بزنه بیرون */
  margin-bottom: -4px;
}
/* ===== GLOBAL SEARCH DROPDOWN ===== */

/* Station */
#itemsTable th:nth-child(1),
#itemsTable td:nth-child(1) {
  width: 75px;
}

/* /* Station Icon */
#itemsTable th:nth-child(2),
#itemsTable td:nth-child(2) {
  width: 55px;
}

/* Level ⭐ */
#itemsTable th:nth-child(3),
#itemsTable td:nth-child(3) {
  width: 55px;
}

/* Tier */
#itemsTable th:nth-child(4),
#itemsTable td:nth-child(4) {
  width: 60px;
}

/* Icon */
#itemsTable th:nth-child(5),
#itemsTable td:nth-child(5) {
  width: 300px;
  text-align: left;
}
.pixel-table {
  min-width: 900px; /* یا هر مقداری که همه ستون‌ها جا بشن */
}
.table-wrapper {
  overflow-x: auto;
  overflow-y: auto;
}

/* Item Name بزرگ‌تر */
#itemsTable th:nth-child(6),
#itemsTable td:nth-child(6) {
  width: 50px;
}

/* بقیه ستون‌ها فشرده */
#itemsTable th:nth-child(n + 7),
#itemsTable td:nth-child(n + 7) {
  width: 90px;
}

.nav-item.dropdown {
  position: relative;
  z-index: 1;
}

.nav-item.dropdown.open {
  z-index: 99999;
}
/* ===== LOCK PAGE SCROLL ===== */

body {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.table-wrapper {
  flex: 1;
  overflow-y: auto;
}
/* Item Name ستون چپ‌چین */
#itemsTable th:nth-child(6),
#itemsTable td:nth-child(6) {
  text-align: center;
  padding-left: 16px;
}
/* ===== CLEAN SKILL DROPDOWN ===== */

.nav-item.dropdown {
  position: relative;
  z-index: 1;
}

.nav-item.dropdown.open {
  z-index: 9999;
}

.nav-item.dropdown.open .dropdown-menu {
  display: flex;
}

.dropdown-menu a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #111a2e;
  color: white;
  text-decoration: none;
  font-size: 14px;
}

.icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.08);
}
.popup-header-item {
  display: flex;
  gap: 20px;
  align-items: center;
  margin-bottom: 16px;
}

.popup-header-meta {
  flex: 1;
  font-size: 14px;
}

.price-box {
  background: #111827;
  padding: 10px 14px;
  border-radius: 10px;
  text-align: center;
  border: 1px solid #2f46ff;
}

.mode-switch {
  display: flex;
  gap: 8px;
  margin: 1px 0;
}

.mode-switch button {
  flex: 1;
  background: #111827;
  border: 1px solid #2f46ff;
  color: white;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
}

.mode-switch button.active {
  background: #2f46ff;
}

.resource-toggle {
  margin-bottom: 16px;
  font-size: 14px;
}

.popup-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 16px;
}

.materials-panel table {
  width: 100%;
  border-collapse: collapse;
}

.materials-panel th,
.materials-panel td {
  padding: 6px;
  border: 1px solid #1f2937;
}

.calc-panel .stat {
  display: flex;
  justify-content: space-between;
  margin: 6px 0;
}

.calc-panel .profit {
  color: #22c55e;
  font-weight: bold;
}
.popup-title-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.popup-title-icon {
  width: 30px;
  height: 30px;
  display: block;
  transform: translateY(-5px);
}
/* ================= STAGE ROW ================= */

.stage-icon-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 11px;
  opacity: 0.9;
}

.stage-icon-wrap img {
  margin-bottom: 2px;
}

.stage-icons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap; /* مهم */
}

/* ============ PRODUCTION SOURCES ============ */

#production-sources {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.production-block {
  padding: 12px 16px;
  border-radius: 12px;
}

.production-title {
  font-size: 14px;
  opacity: 0.9;
  margin-bottom: 8px;
}

.production-stages {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center; /* 🔥 این خط مهمه */
}

.popup-market-title {
  opacity: 0.9;
  margin-bottom: 4px;
}

.popup-market-value {
  background: #111827;
  border: 1px solid #2f46ff;
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 18px;
  font-weight: bold;
}

/* ===== TOP GRID (Production + Market) ===== */
.popup-top-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 1px;
  margin-top: 5px;
  margin-left: 3px;
  margin-right: 3px;
}

.popup-top-left,
.popup-top-middle,
.popup-top-right {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  padding: 10px 12px;
  display: grid;
  grid-template-rows: auto 1fr;
  row-gap: 8px;
  min-height: 88px;
}
.popup-top-right {
  align-items: center;
  justify-items: center;
}

.popup-top-left > .stage-type-label,
.popup-tool-label,
.popup-market-label {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #ffffff;
  opacity: 0.9;
  text-align: center;
}

/* عنوان Market price (بیرون باکس) */
.popup-market-title {
  font-size: 15px;
  font-weight: 600;
  opacity: 0.9;
  margin-bottom: 6px;
  text-align: center;
}

/* عدد داخل باکس */
.popup-market-value {
  background: #111827;
  border: 1px solid #2f46ff;
  padding: 12px 22px;
  border-radius: 14px;
  font-size: 20px;
  font-weight: bold;
  text-align: center;
  min-width: 150px;
}

.ui-icon {
  vertical-align: middle;
  margin-left: 6px;
  opacity: 0.9;
}
.value-unit {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ui-icon.inline {
  width: 13px;
  height: 13px;
  opacity: 0.9;
}

.stage-icon-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 11px;
  opacity: 0.9;
}
.stage-icons-row {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
}

.stage-icon-wrap img {
  width: 36px;
  height: 36px;
}

.stage-type-label {
  font-size: 15px;
  color: #ffffff;
  opacity: 0.9;
  margin-bottom: 6px;
  letter-spacing: 0.3px;
  margin-bottom: 6px;
  text-transform: lowercase;
}

.stage-icons-row {
  display: flex;
  gap: 14px;
}

.stage-icon-wrap span {
  font-size: 12px;
  opacity: 0.9;
}
.popup-tool {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.popup-tool img {
  width: 28px;
  height: 28px;
}
.popup-tool-item {
  display: flex;
  flex-direction: column; /* 👈 مهم */
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.popup-tool-label,
.popup-market-label {
  font-size: 13px;
  font-weight: 600;
  color: #ffffff;
  opacity: 0.9;
}
.popup-market-label {
  margin-right: 11px;
}
.popup-tool-item img {
  width: 30px;
  height: 30px;
}

.popup-tool-item span {
  font-size: 12px;
  font-weight: 600;
}

.popup-market-label {
  font-size: 15px;
  color: #ffffff;
  opacity: 0.9;
  margin-bottom: 4px;
}
.popup-market-price {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 25px;
}

.popup-item-stats span {
  opacity: 0.7;
}

.popup-item-stats b {
  font-weight: 700;
}
.popup-item-stats {
  display: flex;
  align-items: center;
  justify-content: space-between; /* ⬅️ کل عرض */
  width: 100%; /* ⬅️ خیلی مهم */
  padding: 5px 3px; /* فاصله از لبه‌های پاپ‌آپ */
  box-sizing: border-box;
  gap: 10px;
}

.popup-item-stats > div {
  flex: 1; /* ⬅️ کلیدی‌ترین خط */
  display: flex;
  align-items: center;
  justify-content: center; /* ⬅️ متن وسط */
  gap: 6px;
  padding: 8px 6px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}
.popup-tables {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 16px;
  margin-top: 16px;
}

.popup-table-box {
  background: #0f1a2e;
  border-radius: 12px;
  padding: 12px;
}

.popup-table-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 8px;
  opacity: 0.9;
}

.popup-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.popup-table th,
.popup-table td {
  padding: 6px 8px;
  text-align: left;
}

.popup-table th {
  opacity: 0.6;
  font-weight: 500;
}

.popup-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
}

.popup-content th,
.popup-content td {
  padding: 8px;
  text-align: left;
}

/* popup tables */
.popup-table {
  width: 100%;
  border-collapse: collapse;
}
.item-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.popup-table thead th {
  font-weight: 600;
  opacity: 0.7;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.popup-table tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

/* آخرین ردیف خط نداشته باشه */
.popup-table tbody tr:last-child td {
  border-bottom: none;
}

/* hover خیلی لطیف */
.popup-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.04);
}
.price-cell {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.price-cell img.ui-icon {
  width: 13px;
  height: 13px;
  position: relative;
  top: 1px; /* فاین‌تیون */
}
.popup-table th:last-child,
.popup-table td:last-child {
  text-align: right;
}
.item-cell {
  display: flex;
  align-items: center;
  gap: 6px; /* فاصله کنترل‌شده */
}

.item-cell img {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}
.item-cell.clickable {
  cursor: pointer;
}

.item-cell.clickable:active {
  transform: scale(0.98);
}
.ingredient-summary {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 13px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  opacity: 0.85;
}

.summary-row.total {
  font-weight: 600;
  opacity: 1;
}

.summary-divider {
  margin: 6px 0;
  border-top: 1px dashed rgba(255, 255, 255, 0.12);
}
.summary-row.total.cost-good {
  color: #3fd37a; /* سبز */
}

.summary-row.total.cost-bad {
  color: #ff6b6b; /* قرمز */
}
/* Net Profit coloring */
.summary-row.net-profit {
  font-weight: 600;
}

.summary-row.net-profit.profit-good {
  color: #3fd37a; /* سبز */
}

.summary-row.net-profit.profit-bad {
  color: #ff6b6b; /* قرمز */
}
.output-tag {
  margin-left: 6px;
  font-size: 13px;
  opacity: 0.9;
  font-weight: 500;
}
.market-good {
  color: #2ecc71; /* سبز */
  font-weight: 600;
}

.profit-good {
  color: #2ecc71;
}

.profit-bad {
  color: #e74c3c;
}
.popup-back-box {
  position: absolute;
  top: 14px;
  left: 16px;

  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 6px 10px;

  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.1),
    rgba(255, 255, 255, 0.04)
  );

  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;

  color: #fff;
  font-size: 13px;
  font-weight: 500;

  cursor: pointer;
  z-index: 20;

  backdrop-filter: blur(6px);

  transition:
    background 0.2s ease,
    transform 0.15s ease,
    box-shadow 0.2s ease,
    opacity 0.2s ease;
}

.popup-back-box:hover {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.18),
    rgba(255, 255, 255, 0.08)
  );
  transform: translateX(-2px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.popup-back-box:active {
  transform: translateX(-4px) scale(0.97);
}

.popup-back-box:disabled {
  opacity: 0.35;
  cursor: default;
  box-shadow: none;
}

.back-icon {
  font-size: 16px;
  line-height: 1;
}

.back-text {
  font-size: 12px;
  opacity: 0.9;
}
.popup {
  pointer-events: auto;
}

#popup-overlay {
  pointer-events: auto;
}
/* ===============================
   MARKET ONLY POPUP
================================ */

.market-only-popup {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 20px;
}

/* --- Main section --- */
.market-only-main {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px;
  border-radius: 14px;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.03),
    rgba(255, 255, 255, 0.01)
  );
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.market-only-icon {
  width: 72px;
  height: 72px;
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.6));
}

/* --- Info block --- */
.market-only-info {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.market-only-info .info-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  color: #cfd6ff;
}

.market-only-info .info-row span {
  opacity: 0.7;
}

.market-only-info .info-row b {
  font-weight: 600;
  color: #ffffff;
}

/* --- Description --- */
.market-only-desc {
  padding: 18px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.25);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.market-only-desc .desc-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #9aa4ff;
  margin-bottom: 10px;
}

.market-only-desc .desc-box {
  font-size: 14px;
  line-height: 1.6;
  color: #e6e9ff;
  opacity: 0.9;
}

/* --- Optional badge (future ready) --- */
.market-only-badge {
  display: inline-block;
  align-self: flex-start;
  padding: 4px 10px;
  font-size: 11px;
  border-radius: 999px;
  background: linear-gradient(135deg, #7a6cff, #5a4bff);
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.04em;
}

#searchBox::placeholder {
  color: rgba(255, 255, 255, 0.45);
}

#searchBox:focus {
  border-color: #22c55e;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.25);
}
#global-search-results {
  position: absolute;
  background: linear-gradient(
    180deg,
    rgba(10, 15, 40, 0.98),
    rgba(5, 8, 25, 0.98)
  );
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  z-index: 9999;
  backdrop-filter: blur(6px);
}
.search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.search-result-item img {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.search-result-item span {
  font-size: 14px;
  color: #fff;
}

.search-result-item small {
  margin-left: auto;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.45);
}

.search-result-item:hover {
  background: rgba(59, 130, 246, 0.25);
}
.search-result-item.active {
  background: rgba(59, 130, 246, 0.35);
}
.search-hint {
  margin-top: 6px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
}
#searchBox {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: #020617;
  color: #fff;
  outline: none;
}

#searchBox::placeholder {
  color: rgba(255, 255, 255, 0.45);
}

#searchBox:focus {
  border-color: #22c55e;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.25);
}
#global-search-results {
  position: absolute;
  background: #0b1220;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  max-height: 300px;
  overflow-y: auto;
  z-index: 9999;
}
/* ===== SEARCH FONT POLISH ===== */

#searchBox {
  font-family: "Pixelify Sans", system-ui, sans-serif;
  letter-spacing: 0.3px;
}

.search-result-item span {
  font-family: "Pixelify Sans", system-ui, sans-serif;
  font-size: 15px;
}

.search-result-item small {
  font-family: system-ui, sans-serif;
  font-size: 15px;
  opacity: 0.55;
}
#searchBox,
.search-result-item span {
  font-family: "Inter", system-ui, sans-serif;
  font-weight: 600;
}
.profile-menu {
  position: relative;
  margin-left: auto;
  margin-right: 16px;
}

.profile-btn {
  width: 45px;
  height: 45px;
  border-radius: 10px;
  background: #ffb300;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.profile-btn img {
  width: 20px;
  height: 20px;
}

.profile-dropdown {
  position: absolute;
  right: 0;
  top: 46px;
  background: #111827;
  border-radius: 10px;
  padding: 8px;
  min-width: 160px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  z-index: 999;
}

.profile-dropdown a {
  display: block;
  padding: 8px 10px;
  color: #fff;
  text-decoration: none;
  border-radius: 6px;
}

.profile-dropdown a:hover {
  background: rgba(255, 255, 255, 0.08);
}

.hidden {
  display: none;
}
/* ===== AUTH MODAL ===== */

.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-popup);
}

.auth-overlay.hidden {
  display: none;
}

.auth-modal {
  width: 380px;
  background: #0b1220;
  border-radius: 22px;
  padding: 28px 26px;
  border: 1px solid rgba(47, 70, 255, 0.4);
  box-shadow: 0 0 60px rgba(47, 70, 255, 0.4);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-title {
  text-align: center;
  font-size: 22px;
  margin-bottom: 6px;
}

/* Buttons */
.auth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  border: none;
}

.auth-btn img {
  width: 18px;
  height: 18px;
}

/* Providers */
.auth-btn.google {
  background: #fff;
  color: #111;
}

.auth-btn.apple {
  background: #000;
  color: #fff;
}

.auth-btn.email {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
}

.auth-btn.wallet {
  background: linear-gradient(135deg, #7c3aed, #5b21b6);
  color: #fff;
  margin-top: 6px;
}

/* Divider */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0.6;
  font-size: 12px;
}

.auth-divider span {
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.2);
}

/* Footer */
.auth-footer {
  text-align: center;
  font-size: 13px;
  opacity: 0.85;
}

.auth-footer a {
  color: #7aa2ff;
}

.auth-terms {
  font-size: 11px;
  text-align: center;
  opacity: 0.6;
}

.auth-terms a {
  color: #7aa2ff;
}
.auth-btn {
  cursor: not-allowed;
  opacity: 0.85;
}

.auth-btn:hover {
  transform: none;
  box-shadow: none;
}
/* Ingredients: فقط Market Price وسط */
#ingredients-table th:nth-child(3),
#ingredients-table td:nth-child(3) {
  text-align: center !important;
}
#ingredients-table td:nth-child(3) .price-cell {
  justify-content: center;
}
.price-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: nowrap; /* 🔥 مهم */
  flex-wrap: nowrap; /* 🔥 مهم */
}
@media (max-width: 900px) {
  .horizontal-nav {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .horizontal-nav .nav-item {
    flex: 0 0 auto; /* ⬅️ دیگه کش نیاد */
    min-width: max-content;
  }
}
.output-selector {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 10px 0;
}

.output-selector button {
  background: #111827;
  border: 1px solid #2f46ff;
  color: white;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.output-selector button.active {
  background: #2f46ff;
}
#itemsTable td:nth-child(3)::before {
  content: "T";
  font-weight: bold;
  opacity: 0.8;
}

.pixel-table td:nth-child(6)::before {
  content: "x";
  opacity: 0.8;
  margin-right: 2px;
}
/* ===== Popup Variant Selector ===== */

.recipe-selector,
.output-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 8px 0;
  justify-content: center;
}

.recipe-selector button,
.output-selector button {
  background: rgba(255, 255, 255, 0.05);
  color: #cfd8ff;
  border: 1px solid rgba(76, 111, 255, 0.25);
  padding: 6px 50px;
  font-size: 13px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.18s ease;
  backdrop-filter: blur(6px);
}

/* hover */
.recipe-selector button:hover,
.output-selector button:hover {
  background: rgba(76, 111, 255, 0.15);
  border-color: #4c6fff;
  color: #ffffff;
  transform: translateY(-1px);
}

/* active */
.recipe-selector button.active,
.output-selector button.active {
  background: linear-gradient(135deg, #3c5cff, #2f46ff);
  border-color: #4c6fff;
  color: #ffffff;
  box-shadow: 0 0 10px rgba(76, 111, 255, 0.6);
}
.popup-title-text {
  display: flex; /* مهم */
  justify-content: center; /* وسط چین واقعی */
  gap: 8px;
}

/* ===== TABLE SORT ARROWS ===== */

th[data-sort-key] {
  position: relative;
}

/* فلش بالا */
th.sort-asc::after {
  content: "▲";
  position: absolute;
  right: 8px;
  font-size: 10px;
  opacity: 0.9;
}

/* فلش پایین */
th.sort-desc::after {
  content: "▼";
  position: absolute;
  right: 8px;
  font-size: 10px;
  opacity: 0.9;
}
/* ===== ICON SIZE CONTROL ===== */

/* Item Icons */
.item-icon {
  width: 24px !important;
  height: 24px !important;
  flex-shrink: 0;
}

/* UI Icons */
.ui-icon {
  width: 14px !important;
  height: 14px !important;
}
.popup-market-price img {
  width: 16px !important;
  height: 16px !important;
}
/* Numeric cells */
#itemsTable td {
  font-weight: 500;
}

/* ستون‌های قیمت و سود کمی ضخیم‌تر */
#itemsTable td:nth-child(7),
#itemsTable td:nth-child(8),
#itemsTable td:nth-child(9) {
  font-weight: 600;
  letter-spacing: 0.3px;
}
#itemsTable td {
  font-variant-numeric: tabular-nums;
}
.stage-type-label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.land-icons {
  display: flex;
  gap: 5px;
}

.land-type-icon {
  width: 20px;
  height: 20px;
}
#header,
#navbar {
  flex-shrink: 0;
}

.container,
.table-wrapper {
  flex: 1;
}

#footer {
  flex-shrink: 0;
}
