*{box-sizing:border-box}
:root{
  --bg1:#020617;--bg2:#071b34;--card1:rgba(15,23,42,.82);--card2:rgba(21,34,67,.7);
  --line:rgba(255,255,255,.11);--text:#e5edf8;--muted:#9db0d0;--good:#34d399;--bad:#fb7185;--warn:#fbbf24;
}
html,body{margin:0;min-height:100%}
body{
  font-family:Tahoma,Arial,sans-serif;color:var(--text);
  background:radial-gradient(circle at top right, rgba(0,153,255,.20), transparent 28%),
             radial-gradient(circle at bottom center, rgba(86,65,255,.16), transparent 24%),
             linear-gradient(180deg, #021127 0%, #020817 100%);
}
.page-shell{max-width:1280px;margin:0 auto;padding:26px 18px 28px}
.glass{
  background:linear-gradient(90deg, var(--card1), var(--card2));
  border:1px solid var(--line);border-radius:26px;
  box-shadow:0 10px 30px rgba(0,0,0,.28), inset 0 1px 0 rgba(255,255,255,.03);
  backdrop-filter:blur(10px)
}
.topbar,.status-card,.footer{display:flex;justify-content:space-between;align-items:center}
.topbar{padding:14px 18px;margin-bottom:14px}
.brand{display:flex;align-items:center;gap:12px}.brand-icon{width:48px;height:48px;border-radius:16px;display:flex;align-items:center;justify-content:center;background:linear-gradient(180deg, rgba(79,140,255,.22), rgba(109,77,255,.16));border:1px solid rgba(255,255,255,.09);font-size:24px}
.brand-title{font-size:28px;font-weight:700}.brand-sub{font-size:13px;color:var(--muted)}.top-actions{display:flex;gap:10px}
.icon-btn,.ghost-btn,.primary-btn{border:none;cursor:pointer;color:#fff;border-radius:14px;font-weight:700}
.icon-btn{width:44px;height:44px;background:rgba(10,20,40,.75);border:1px solid rgba(255,255,255,.08)}
.hero{padding:26px 18px;margin-bottom:14px;background:linear-gradient(135deg, rgba(53,87,175,.58), rgba(51,28,120,.65))}
.hero h1{margin:0 0 8px;font-size:26px}.hero p{margin:0;color:#dbe7ff}
.controls{display:grid;grid-template-columns:repeat(5,1fr);gap:14px;padding:16px;margin-bottom:14px}
.field{display:flex;flex-direction:column;gap:8px}.field label{font-size:13px;color:var(--muted)}
.field select,.field input,.primary-btn{
  width:100%;min-height:48px;padding:12px 14px;border-radius:14px;border:1px solid rgba(255,255,255,.10);background:#0a1630;color:#fff;font-size:15px
}
.primary-btn{background:linear-gradient(180deg, #3478ff, #295de0)} .primary-btn:disabled{opacity:.65;cursor:not-allowed}
.status-card{padding:16px 18px;margin-bottom:14px}.muted{color:var(--muted);font-size:13px}
.content-grid{display:grid;grid-template-columns:.9fr 1.1fr;gap:14px}.panel{padding:18px}
.panel-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:14px}.panel-head h2{margin:0;font-size:22px}
.chip{
	background:rgba(255,255,255,.07);
	border:1px solid rgba(255,255,255,.08);
	color:#dbe7ff;
	padding: 6px 10px;
	border-radius:999px;
	font-size:12px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.info-card,.ingredient-card{background:rgba(6,16,35,.72);border:1px solid rgba(255,255,255,.08);border-radius:18px;padding:16px}
.info-label{font-size:13px;color:var(--muted);margin-bottom:8px}.info-value{font-size:22px;font-weight:700}.good{color:var(--good)}.bad{color:var(--bad)}
.ingredients-list{display:flex;flex-direction:column;gap:12px}

.small-item-icon {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.03);
    border-radius: 12px;
}

.ingredient-title {
    display: flex;
    align-items: center;
    justify-content: center; /* يخلي الاسم بالنص */
    position: relative;
	margin-top: -25px;
}

.title-with-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.ingredient-title .chip {
	position: absolute;
    left: 10px;
    top: -0px; /* 👈 نرفعه فوق */
    left: 0;
}

.ingredient-title span:not(.chip) {
    font-weight: 600;
    font-size: 20px;
}

.ingredients-list .item-icon {
    width: 32px;
    height: 32px;
}

.ingredient-meta{font-size:14px;line-height:1.9;color:#dce7f8}
.mini-note{margin-top:10px;padding:10px 12px;border-radius:14px;background:rgba(251,191,36,.08);border:1px solid rgba(251,191,36,.20);color:#fde68a;font-size:13px}
.empty-state{color:var(--muted);display:flex;align-items:center;justify-content:center;min-height:100px;text-align:center}
.footer{margin-top:14px;padding:18px;color:#d5def1}
.logs-box{max-height:320px;overflow:auto;background:rgba(5,10,22,.72);border:1px solid rgba(255,255,255,.08);border-radius:18px;padding:16px;font-family:Consolas,monospace;font-size:13px;line-height:1.8;white-space:pre-wrap}
.hidden{display:none}.ghost-btn{background:rgba(255,255,255,.06);border:1px solid rgba(255,255,255,.08);padding:10px 14px}
@media (max-width:980px){.controls,.content-grid,.summary-grid{grid-template-columns:1fr}.status-card,.footer{flex-direction:column;align-items:flex-start;gap:6px}}

.recipe-form-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:14px;margin-bottom:14px}
.recipe-actions{margin-top:14px}
textarea{
  width:100%;min-height:140px;padding:12px 14px;border-radius:14px;
  border:1px solid rgba(255,255,255,.10);background:#0a1630;color:#fff;font-size:15px;resize:vertical
}
@media (max-width:980px){.recipe-form-grid{grid-template-columns:1fr}}

.recipe-form-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:14px;margin-bottom:14px}
.recipe-actions{margin-top:14px}
.ingredient-builder{display:flex;flex-direction:column;gap:12px;margin-top:8px}
.ingredient-row{
  display:grid;grid-template-columns:1.15fr 1.15fr .7fr .9fr .9fr auto;gap:10px;
  background:rgba(6,16,35,.55);border:1px solid rgba(255,255,255,.08);
  border-radius:16px;padding:12px
}
.ingredient-row select{
  width:100%;min-height:44px;padding:10px 12px;border-radius:12px;
  border:1px solid rgba(255,255,255,.10);background:#0a1630;color:#fff;font-size:14px
}
.ingredient-row .field{gap:6px}
.ingredient-row input{
  width:100%;min-height:44px;padding:10px 12px;border-radius:12px;
  border:1px solid rgba(255,255,255,.10);background:#0a1630;color:#fff;font-size:14px
}
.row-remove-btn,.add-row-btn{align-self:end}
textarea{
  width:100%;min-height:140px;padding:12px 14px;border-radius:14px;
  border:1px solid rgba(255,255,255,.10);background:#0a1630;color:#fff;font-size:15px;resize:vertical
}
@media (max-width:980px){
  .recipe-form-grid{grid-template-columns:1fr}
  .ingredient-row{grid-template-columns:1fr}
}
.item-icon {
    object-fit: contain;
    image-rendering: pixelated;
    position: relative;
    top: 1px; /* عدلها لو حسيت انها مرتفعة */
}

.summary-grid .info-card:first-child,
.summary-grid .info-card.weekly-card {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
	flex-direction: column;
}

.summary-grid .info-card:first-child .info-value {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
}

.summary-grid .info-card:first-child .title-with-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
}

.summary-grid .info-card:first-child .item-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
    image-rendering: pixelated;
    vertical-align: middle;
    position: relative;
    top: 1px;
}

.summary-grid .info-card:first-child .title-with-icon span {
    display: inline-flex;
    align-items: center;
}

.recipe-form-grid-4{grid-template-columns:repeat(4,1fr)}
@media (max-width:980px){.recipe-form-grid-4{grid-template-columns:1fr}}


.summary-grid .info-card:first-child .info-label {
    display: none;
}

.summary-grid .info-card:first-child .info-value.item-summary-value {
    width: 100%;
    flex-direction: column;
    gap: 10px;
}

.item-summary-head {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 14px;
}

.item-summary-label {
    color: var(--muted);
}

.item-summary-recipe {
    color: #4fd1c5;
    font-weight: 700;
}

.summary-grid .info-card:first-child .title-with-icon {
    font-size: 20px;
    font-weight: 700;
}


.craft-amount-box{
  min-height:48px;
  display:flex;
  align-items:center;
  gap:12px;
  padding:8px 10px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.10);
  background:#0a1630;
}
.craft-amount-box-input input{
  width:110px;
  min-height:44px;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.10);
  background:rgba(255,255,255,.04);
  color:#fff;
  font-size:18px;
  font-weight:700;
  text-align:center;
}
.craft-amount-box-input input::-webkit-outer-spin-button,
.craft-amount-box-input input::-webkit-inner-spin-button{
  -webkit-appearance:none;
  margin:0;
}
.craft-amount-box-input input[type=number]{
  -moz-appearance:textfield;
}
.craft-amount-display{
  flex:1;
  text-align:center;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:2px;
}
#craftAmountValue{
  font-size:18px;
  font-weight:700;
  line-height:1.1;
}
.craft-amount-meta{
  font-size:12px;
  color:var(--muted);
}




/* Recipe editor ingredient row delete icon */
.ingredient-row{
  position:relative;
  grid-template-columns:1.15fr 1.15fr .7fr .9fr .9fr auto;
  padding:12px 12px 12px 56px;
}

.row-remove-icon-btn{
  position:absolute;
  left:12px;
  top:12px;
  width:30px;
  height:30px;
  border:none;
  border-radius:999px;
  background:rgba(255,77,79,.12);
  color:#ff4d4f;
  font-size:18px;
  font-weight:700;
  line-height:1;
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  z-index:2;
  transition:.18s ease;
}

.row-remove-icon-btn:hover{
  background:rgba(255,77,79,.22);
  transform:scale(1.08);
}

.row-remove-icon-btn:active{
  transform:scale(.96);
}

.ingredient-icon-preview-wrap{
  display:flex;
  flex-direction:column;
  gap:6px;
}

.ingredient-icon-preview{
  width:64px;
  height:64px;
  display:flex;
  align-items:center;
  justify-content:center;
  border-radius:12px;
  background:rgba(255,255,255,.03);
  overflow:hidden;
}

.ingredient-icon-preview img.small-item-icon,
.small-item-icon{
  width:48px !important;
  height:48px !important;
  object-fit:contain !important;
  image-rendering:pixelated !important;
  display:block;
}

@media (max-width:980px){
  .ingredient-row{padding-left:12px;padding-top:52px}
  .row-remove-icon-btn{left:12px;top:10px}
}


.ingredient-stats {
    display: flex;
    gap: 10px;
    align-items: stretch;
    justify-content: center;
    flex-wrap: nowrap; /* 👈 يمنع النزول */
}

.ingredient-stat-box {
	max-width: 120px;
	flex: 1;
    min-width: 140px;
    padding: 8px 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    text-align: center;
}

.ingredient-stat-label {
    font-size: 12px;
    color: #9fb3d9;
    line-height: 1.2;
}

.ingredient-stat-value {
    font-size: 14px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.2;
}

.ingredient-card {
    padding-top: 36px; /* 👈 هذا يفصلهم */
}
/* Compact top controls */
.compact-controls{
  grid-template-columns:1.2fr 1fr .9fr .9fr .9fr .9fr;
  align-items:end;
}

.compact-controls .field{
  min-width:0;
}

.compact-controls .field label{
  font-size:12px;
  margin-bottom:4px;
}

.compact-controls select,
.compact-controls input,
.compact-controls .primary-btn{
  min-height:42px;
  height:42px;
  padding:10px 12px;
  font-size:14px;
}

.compact-controls .field-mode select{
  font-size:13px;
  padding-inline:10px;
}

.compact-controls .action-field .primary-btn{
  width:100%;
}

.compact-craft-box{
  min-height:42px;
  height:42px;
  padding:0 10px;
  justify-content:center;
}

.compact-craft-box input{
  width:100% !important;
  min-height:0 !important;
  height:100%;
  padding:0 !important;
  border:none !important;
  background:transparent !important;
  font-size:18px !important;
  font-weight:700;
  text-align:center;
}

.compact-craft-meta{
  margin-top:6px;
  text-align:center;
  font-size:11px;
  line-height:1.2;
}

/* hide old two-part craft display if present */
#craftAmountValue,
.craft-amount-display{
  display:none;
}

@media (max-width: 1180px){
  .compact-controls{
    grid-template-columns:repeat(3,1fr);
  }
}

@media (max-width: 760px){
  .compact-controls{
    grid-template-columns:1fr;
  }
}


.final-amount-badge {
    padding: 6px 14px;
    border-radius: 999px;
    background: rgba(79, 209, 197, 0.15);
    color: #4fd1c5;
    font-size: 14px;
    font-weight: 700;
    text-align: center;
    min-width: 120px;
}
/* ===================================================
   نظام الحسابات + لوحة أفضل وصفة
   =================================================== */

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.14);
    white-space: nowrap;
}

.auth-shell {
    max-width: 520px;
}

.auth-panel {
    margin-top: 24px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-form .field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.auth-form .field span {
    font-size: 13px;
    opacity: 0.8;
}

.auth-form input {
    width: 100%;
}

.auth-error {
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 14px;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.4);
}

.auth-alt {
    margin: 0;
    text-align: center;
    font-size: 13px;
    opacity: 0.85;
}

.auth-alt a {
    color: inherit;
    font-weight: 700;
    text-decoration: underline;
}

.best-head-actions {
    display: flex;
    gap: 8px;
}

.best-row {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.best-rank {
    font-weight: 800;
    font-size: 15px;
    opacity: 0.7;
    min-width: 34px;
}

.best-main {
    flex: 1 1 160px;
}

.best-title {
    font-weight: 700;
}

.best-metrics {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    font-size: 13px;
}

.best-metrics .positive,
.info-card.positive .info-value {
    color: #4ade80;
}

.best-metrics .negative,
.info-card.negative .info-value {
    color: #f87171;
}

.info-card.highlight {
    border-color: rgba(250, 204, 21, 0.45);
    background: rgba(250, 204, 21, 0.08);
}

/* الوصفات العامة */
.public-toggle-field { margin-top: 6px; }
.public-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
}
.public-toggle input { width: 18px; height: 18px; accent-color: #f5a623; cursor: pointer; }
.public-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}
.public-row .best-sub { opacity: .75; font-size: 13px; margin-top: 4px; }
.public-row .primary-btn { white-space: nowrap; }

/* ===== شريط الأدوات العلوي (نسخة محسّنة) ===== */
.top-actions{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
  padding:8px;
  border-radius:20px;
  background:rgba(6,14,30,.55);
  border:1px solid rgba(255,255,255,.07);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.04);
}

.top-actions .icon-btn{
  width:46px;
  height:46px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:19px;
  line-height:1;
  border-radius:16px;
  background:linear-gradient(180deg, rgba(20,33,60,.95), rgba(11,20,40,.95));
  border:1px solid rgba(255,255,255,.09);
  box-shadow:0 6px 14px rgba(0,0,0,.28);
  text-decoration:none;
  transition:transform .16s ease, border-color .16s ease, background .16s ease;
}

.top-actions .icon-btn:hover{
  transform:translateY(-2px);
  border-color:rgba(79,140,255,.55);
  background:linear-gradient(180deg, rgba(35,58,110,.95), rgba(16,29,58,.95));
}

.top-actions .icon-btn:active{transform:translateY(0) scale(.96)}

.top-actions .user-chip{
  height:46px;
  padding:0 18px;
  border-radius:999px;
  font-size:15px;
  background:linear-gradient(180deg, rgba(28,44,80,.95), rgba(14,24,48,.95));
  border:1px solid rgba(255,255,255,.12);
}

.top-actions a.icon-btn[href="logout.php"]{
  color:#fda4af;
  border-color:rgba(251,113,133,.28);
}
.top-actions a.icon-btn[href="logout.php"]:hover{
  border-color:rgba(251,113,133,.6);
  background:linear-gradient(180deg, rgba(80,25,40,.9), rgba(40,14,24,.95));
}

@media (max-width:760px){
  .topbar{flex-direction:column;align-items:stretch;gap:12px}
  .top-actions{justify-content:center}
}

/* ===== اختيار ترتيب أفضل الوصفات ===== */
.panel-subhead{gap:12px;flex-wrap:wrap}
.best-sort-wrap{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
}
.best-sort-wrap label{font-size:13px;color:var(--muted)}
.best-sort-wrap select{
  min-height:40px;
  padding:8px 12px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.10);
  background:#0a1630;
  color:#fff;
  font-size:14px;
}

/* ===== وصف القطعة (Bazaar tooltip) + مقارنة NPC ===== */
.market-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
}

.mc-tooltip {
    background: rgba(12, 8, 24, 0.92);
    border: 2px solid rgba(120, 80, 200, 0.55);
    border-radius: 10px;
    padding: 14px 16px;
    font-family: "Consolas", "Courier New", monospace;
    line-height: 1.7;
    direction: ltr;
    text-align: left;
}

.mc-title { color: #55ffff; font-weight: 700; font-size: 1.05rem; }
.mc-sub { color: #9b8fb5; margin-bottom: 10px; font-size: .85rem; }
.mc-block { margin-top: 10px; }
.mc-key { color: #e8e3f5; }
.mc-coins { color: #ffd15c; font-weight: 700; }
.mc-dim { color: #8b849c; font-size: .85rem; direction: rtl; text-align: right; }

.npc-compare {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 12px;
    padding: 14px 16px;
}

.npc-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    font-size: .92rem;
}

.npc-row b { font-variant-numeric: tabular-nums; }

.npc-verdict {
    margin-top: 6px;
    padding: 10px 12px;
    border-radius: 10px;
    font-weight: 700;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.npc-verdict.npc { background: rgba(255, 196, 0, 0.14); border: 1px solid rgba(255, 196, 0, 0.35); }
.npc-verdict.bazaar { background: rgba(80, 220, 160, 0.13); border: 1px solid rgba(80, 220, 160, 0.35); }
.npc-diff { font-weight: 500; opacity: .8; font-size: .85rem; }

/* ===== اقتراحات ربح ===== */
.suggest-note{margin:0 0 14px}
.suggest-filters{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:12px;align-items:end;margin-bottom:16px}
.suggest-check{display:flex;align-items:center;gap:8px;font-size:13px;color:var(--muted);padding-bottom:12px;cursor:pointer}
.suggest-filters .chip{justify-self:center}
