:root {
  --sky: #29ABE2;
  --sky-dark: #1f8fc0;
  --orange: #F7941D;
  --orange-dark: #e07d0a;
  --yellow: #FFD700;
  --ink: #16384a;
  --bg: #f3fafe;
  --card: #ffffff;
  --ok: #2e9e5b;
  --ok-light: #e8f8ee;
  --err: #d64545;
  --err-light: #fcebeb;
  --muted: #7a93a3;
  --border: #e2eef4;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  font-family: 'Cairo', sans-serif;
  background:
    radial-gradient(circle at 10% 0%, rgba(41,171,226,0.10), transparent 40%),
    radial-gradient(circle at 90% 100%, rgba(247,148,29,0.10), transparent 40%),
    var(--bg);
  color: var(--ink);
  direction: rtl;
  min-height: 100vh;
  padding-bottom: 30px;
}

/* ===== Topbar ===== */
.topbar {
  background: linear-gradient(120deg, var(--sky), var(--sky-dark));
  color: #fff;
  box-shadow: 0 4px 18px rgba(31,143,192,0.25);
  position: sticky; top: 0; z-index: 50;
}
.topbar-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 20px;
}
.brand {
  font-weight: 800; font-size: 22px; letter-spacing: .3px;
  color: #fff; text-decoration: none;
}
.brand span { color: var(--yellow); }
.topbar-user { font-size: 14px; display: flex; align-items: center; gap: 12px; }
.topbar-user .hello { opacity: .9; }
.topbar-user .logout {
  color: #fff; text-decoration: none; font-weight: 700;
  background: rgba(255,255,255,.18); padding: 5px 12px; border-radius: 20px;
  font-size: 13px;
}
.topbar-user .logout:hover { background: rgba(255,255,255,.30); }

/* ===== Nav tabs ===== */
.nav-tabs {
  display: flex;
  background: rgba(0,0,0,.10);
  padding: 0 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-tabs::-webkit-scrollbar { display: none; }
.nav-tab {
  flex: 1; min-width: 100px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 14px;
  color: rgba(255,255,255,.78);
  text-decoration: none; font-weight: 700; font-size: 15px;
  border-bottom: 3px solid transparent;
  transition: color .15s, border-color .15s, background .15s;
  white-space: nowrap;
}
.nav-tab:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav-tab.active {
  color: #fff; border-bottom-color: var(--yellow);
  background: rgba(255,255,255,.08);
}
.nav-ic { font-size: 17px; }

/* ===== Main wrap ===== */
.wrap { max-width: 620px; margin: 24px auto; padding: 0 16px; }
.wrap-wide { max-width: 880px; }

.card {
  background: var(--card);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 10px 40px rgba(22,56,74,0.08);
  border: 1px solid rgba(41,171,226,0.12);
}

.page-title { font-size: 20px; font-weight: 800; color: var(--ink); margin-bottom: 6px; }
.page-sub { color: var(--muted); font-size: 14px; line-height: 1.7; margin-bottom: 18px; }

/* ===== Inline tabs (sale/return) ===== */
.tabs { display: flex; gap: 10px; margin-bottom: 22px; }
.tab {
  flex: 1; padding: 12px; border-radius: 12px; border: none;
  font-family: inherit; font-weight: 700; font-size: 16px; cursor: pointer;
  background: #eaf6fc; color: var(--muted); transition: .2s;
}
.tab.active.sell { background: var(--sky); color: #fff; }
.tab.active.ret  { background: var(--orange); color: #fff; }

/* ===== Forms ===== */
label { display: block; font-weight: 600; margin: 14px 0 6px; font-size: 14px; }
input, textarea, select {
  width: 100%; padding: 13px 14px; border-radius: 12px;
  border: 2px solid var(--border); font-family: inherit; font-size: 16px;
  background: #fbfdff; transition: .15s; color: var(--ink);
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--sky); background: #fff;
}

.row2 { display: flex; gap: 12px; }
.row2 > div { flex: 1; }

/* ===== Buttons ===== */
.btn {
  width: 100%; padding: 15px; border: none; border-radius: 14px;
  font-family: inherit; font-weight: 800; font-size: 17px; cursor: pointer;
  margin-top: 20px; color: #fff; transition: .2s; box-shadow: 0 6px 18px rgba(0,0,0,.10);
}
.btn.sell { background: linear-gradient(120deg, var(--sky), var(--sky-dark)); }
.btn.ret  { background: linear-gradient(120deg, var(--orange), var(--orange-dark)); }
.btn.btn-add { background: linear-gradient(120deg, #57bf85, #2e9e5b); }
.btn:hover:not(:disabled) { transform: translateY(-2px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn-ghost {
  background: #eaf6fc; color: var(--sky); box-shadow: none;
  border: 2px solid rgba(41,171,226,.3); margin-top: 8px;
}

/* ===== Multi-item sale rows ===== */
.sale-row {
  position: relative;
  padding: 14px 14px 12px;
  border: 2px dashed #d6e7f0;
  border-radius: 14px;
  background: #fbfdff;
  margin-bottom: 12px;
}
.sale-row .row-del {
  position: absolute; top: 8px; left: 8px;
  width: 28px; height: 28px; border-radius: 50%;
  background: #fcebeb; color: var(--err); border: none;
  font-weight: 800; cursor: pointer; font-family: inherit;
  display: flex; align-items: center; justify-content: center;
}
.sale-row .row-del:hover { background: var(--err); color: #fff; }
.sale-row .row-fields {
  display: grid;
  grid-template-columns: 1.4fr 0.7fr 1fr 0.8fr;
  gap: 8px;
}
.sale-row .row-fields input {
  padding: 11px 12px; font-size: 15px; margin: 0;
}
.row-info {
  margin-top: 8px; font-size: 13px; font-weight: 600;
  color: var(--muted); min-height: 18px;
}
.row-info.ok  { color: var(--ok); }
.row-info.err { color: var(--err); }

@media (max-width: 520px) {
  .sale-row .row-fields {
    grid-template-columns: 1fr 1fr;
  }
}

/* ===== Info / message boxes ===== */
.info {
  margin-top: 16px; padding: 16px; border-radius: 14px;
  background: #f0f9ff; border: 1px dashed var(--sky); display: none;
}
.info.show { display: block; }
.info .name { font-weight: 800; font-size: 17px; margin-bottom: 6px; }
.info .meta { color: var(--muted); font-size: 14px; line-height: 1.9; }
.info .meta b { color: var(--ink); }

.msg { margin-top: 18px; padding: 14px 16px; border-radius: 12px; font-weight: 600; display: none; line-height: 1.6; }
.msg.show { display: block; }
.msg.ok { background: var(--ok-light); color: var(--ok); border: 1px solid #bfe8cd; }
.msg.err { background: var(--err-light); color: var(--err); border: 1px solid #f3c9c9; }
.msg ul { margin: 8px 14px 0; font-weight: 500; }

/* ===== Sync page ===== */
.sync-actions {
  display: grid; gap: 14px; grid-template-columns: 1fr 1fr; margin-top: 8px;
}
.sync-btn {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 16px; border-radius: 16px; border: none;
  font-family: inherit; cursor: pointer; color: #fff;
  text-align: right; transition: .2s; box-shadow: 0 6px 18px rgba(0,0,0,.10);
}
.sync-btn:hover:not(:disabled) { transform: translateY(-2px); }
.sync-btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.sync-btn.sky    { background: linear-gradient(120deg, var(--sky), var(--sky-dark)); }
.sync-btn.orange { background: linear-gradient(120deg, var(--orange), var(--orange-dark)); }
.sync-ic { font-size: 30px; line-height: 1; }
.sync-txt { display: flex; flex-direction: column; gap: 2px; }
.sync-txt b { font-size: 16px; font-weight: 800; }
.sync-txt small { font-size: 12px; opacity: .9; font-weight: 600; }

.sync-details { margin-top: 14px; }
.sync-details h4 { margin: 12px 0 6px; font-size: 14px; color: var(--ink); }
.sync-details ul { list-style: none; padding: 0; }
.sync-details li {
  padding: 6px 10px; margin: 4px 0; border-radius: 8px;
  background: #f7fbfd; border: 1px solid var(--border); font-size: 13px; color: var(--muted);
}
.sync-details code {
  background: var(--ink); color: #fff; padding: 1px 7px; border-radius: 6px;
  font-size: 12px; margin-left: 6px;
}

@media (max-width: 520px) {
  .sync-actions { grid-template-columns: 1fr; }
}

/* ===== Upload images page ===== */
.item-card {
  border: 2px dashed #d6e7f0;
  border-radius: 16px;
  padding: 16px;
  margin-top: 14px;
  background: #fbfdff;
  transition: border-color .2s, background .2s;
}
.item-card.busy { border-color: var(--sky); background: #f0f9ff; border-style: solid; }
.item-card.ok   { border-color: var(--ok);  background: var(--ok-light);  border-style: solid; }
.item-card.err  { border-color: var(--err); background: var(--err-light); border-style: solid; }
.item-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 4px;
}
.item-head .idx {
  background: var(--sky); color: #fff; width: 28px; height: 28px;
  border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800;
}
.item-head .title { font-weight: 700; font-size: 15px; color: var(--ink); }
.remove-btn {
  margin-right: auto; background: transparent; border: none; color: var(--err);
  font-weight: 700; cursor: pointer; font-size: 14px; font-family: inherit;
  padding: 6px 10px; border-radius: 8px;
}
.remove-btn:hover { background: rgba(214,69,69,.1); }

.file-drop {
  display: block; cursor: pointer;
  padding: 22px; border: 2px dashed var(--sky); border-radius: 14px;
  background: #f0f9ff; text-align: center; transition: .2s;
  margin-top: 4px;
}
.file-drop:hover, .file-drop.drag { background: #e1f3fc; border-color: var(--sky-dark); }
.file-drop-text {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-weight: 700; color: var(--sky-dark); font-size: 15px;
}
.file-drop-ic { font-size: 22px; }

.thumbs-wrap { margin-top: 14px; }
.thumbs-hint {
  font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 8px;
}
.thumbs {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
}
.thumb {
  position: relative;
  background: #fff; border-radius: 12px; overflow: hidden;
  border: 2px solid var(--border);
  cursor: grab; touch-action: none;
  user-select: none; -webkit-user-select: none;
  transition: border-color .15s, box-shadow .15s;
}
.thumb:hover { border-color: var(--sky); box-shadow: 0 4px 14px rgba(31,143,192,.18); }
.thumb:active { cursor: grabbing; }
.thumb.thumb-ghost { opacity: .35; }
.thumb img {
  width: 100%; aspect-ratio: 1 / 1; object-fit: cover; display: block;
  pointer-events: none;
}
.thumb-idx {
  position: absolute; top: 6px; right: 6px;
  background: var(--sky); color: #fff;
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.thumb-del {
  position: absolute; top: 6px; left: 6px;
  width: 26px; height: 26px; border-radius: 50%;
  background: rgba(214,69,69,.95); color: #fff; border: none;
  font-weight: 800; font-size: 13px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.thumb-del:hover { background: var(--err); }
.thumb-name {
  font-size: 11px; padding: 6px 8px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: #fbfdff; border-top: 1px solid var(--border);
}

.toolbar {
  display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap;
}
.toolbar .btn { margin-top: 0; flex: 1; min-width: 160px; }

.status-line { margin-top: 10px; font-size: 13px; font-weight: 700; min-height: 18px; }
.status-line.ok  { color: var(--ok); }
.status-line.err { color: var(--err); }

/* ===== Login ===== */
.login-wrap { max-width: 400px; margin: 90px auto; padding: 0 16px; }
.login-logo { text-align: center; font-size: 30px; font-weight: 800; margin-bottom: 6px; color: var(--sky); }
.login-logo span { color: var(--orange); }
.login-sub { text-align: center; color: var(--muted); margin-bottom: 24px; }

/* ===== Mobile tuning ===== */
@media (max-width: 480px) {
  .topbar-row { padding: 10px 14px; }
  .brand { font-size: 19px; }
  .topbar-user .hello { display: none; }
  .nav-tab { font-size: 13px; padding: 11px 8px; min-width: 0; }
  .nav-ic { font-size: 16px; }
  .nav-lbl { font-size: 13px; }
  .wrap { margin: 16px auto; padding: 0 12px; }
  .card { padding: 18px; border-radius: 16px; }
  .page-title { font-size: 18px; }
  .thumbs { grid-template-columns: repeat(auto-fill, minmax(95px, 1fr)); }
  .toolbar { flex-direction: column; }
}
