/* SHEIN Scanner dashboard - Arabic RTL, responsive (desktop 1366-1920, phone 360-430). No framework. */
:root {
  --bg: #f3f4f6; --card: #fff; --ink: #1f2430; --muted: #6b7280; --line: #e5e7eb; --head: #111318;
  --ok: #0f7b3f; --okbg: #e7f6ee; --warn: #8a5300; --warnbg: #fff4dd; --bad: #b3261e; --badbg: #fdecea;
  --run: #1b5fb8; --runbg: #e8f0fc; --radius: 10px; --gap: 12px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.5 "Noto Sans Arabic", "Segoe UI", Tahoma, Arial, sans-serif; }
a { color: var(--run); text-decoration: none; } a:hover { text-decoration: underline; }
bdi, .num, .ltr { unicode-bidi: isolate; } .num, .ltr { direction: ltr; }
.num { font-variant-numeric: tabular-nums; }

/* ---- header / navigation (compact, sticky) ---- */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px;
  height: 48px; padding: 0 20px; background: var(--head); color: #fff; }
.brand { font-weight: 700; font-size: 15px; white-space: nowrap; }
.tag { font-size: 11px; font-weight: 400; background: #2d313a; border-radius: 5px; padding: 1px 6px; margin-inline-start: 6px; }
nav { display: flex; gap: 2px; }
nav a { color: #c9ccd3; padding: 6px 12px; border-radius: 7px; font-size: 13.5px; white-space: nowrap; }
nav a:hover { background: #2a2e37; color: #fff; text-decoration: none; }
nav a.on { background: #fff; color: var(--head); font-weight: 600; }
.logout { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; }
.logout .who { color: #9ca3af; font-size: 12.5px; }
.logout button { min-height: 28px; padding: 2px 12px; font-size: 12.5px; background: transparent; color: #e5e7eb; border-color: #4b5563; }
.card.login { max-width: 420px; margin-top: 40px; }
input[type=text], input[type=password] { display: block; width: 100%; margin-top: 4px; padding: 8px 10px;
  border: 1px solid #d1d5db; border-radius: 8px; font: inherit; background: #fff; min-height: 38px; }
.banner { background: var(--runbg); color: var(--run); padding: 6px 20px; font-size: 13px; }

/* ---- page frame ---- */
main { max-width: 1440px; margin: 0 auto; padding: 16px 20px 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; margin-bottom: var(--gap); }
.card.narrow { max-width: 760px; margin-inline: auto; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--gap); }
h1 { font-size: 18px; margin: 0 0 10px; } h2 { font-size: 15px; margin: 14px 0 8px; }
.card > h2:first-child { margin-top: 0; }
p { margin: 6px 0; }
.hint { color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .strong { font-weight: 700; }
.ok { color: var(--ok); font-weight: 600; } .warn { color: var(--warn); font-weight: 600; } .req { color: var(--bad); }
.alert { background: var(--badbg); color: var(--bad); padding: 8px 12px; border-radius: 8px; margin: 8px 0; }
footer { text-align: center; color: var(--muted); font-size: 12px; padding: 12px 16px 20px; }

/* ---- forms ---- */
label { display: block; margin: 10px 0; font-weight: 600; font-size: 13.5px; }
input[type=url], input[type=number], input[type=file] { display: block; width: 100%; margin-top: 4px; padding: 8px 10px;
  border: 1px solid #d1d5db; border-radius: 8px; font: inherit; background: #fff; min-height: 38px; }
input:focus { outline: 2px solid #93b4e8; outline-offset: 0; border-color: #93b4e8; }
input.qtyin { width: 72px; min-height: 32px; padding: 4px 8px; margin: 0; }
button, .button { display: inline-flex; align-items: center; justify-content: center; font: inherit; font-weight: 600;
  min-height: 36px; padding: 6px 18px; border-radius: 8px; border: 1px solid var(--head); background: #fff;
  color: var(--head); cursor: pointer; text-decoration: none; }
button[type=submit], button.primary { background: var(--head); color: #fff; }
button:disabled { opacity: .45; cursor: not-allowed; }

/* ---- pills ---- */
.pill { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: #eef0f3; color: #4b5563; white-space: nowrap; }
.pill.st-completed { background: var(--okbg); color: var(--ok); }
.pill.st-failed, .pill.st-interrupted, .pill.st-needs_attention, .pill.st-blocked { background: var(--badbg); color: var(--bad); }
.pill.st-awaiting_quantities, .pill.st-cleaning_failed { background: var(--warnbg); color: var(--warn); }
.pill.st-starting, .pill.st-cleaning, .pill.st-reading_basket, .pill.st-importing, .pill.st-quantities,
.pill.st-validating, .pill.st-reading_checkout, .pill.st-verifying_retained, .pill.st-running,
.pill.st-discovering, .pill.st-ready { background: var(--runbg); color: var(--run); }
.best { display: inline-block; font-size: 11px; background: var(--okbg); color: var(--ok); border-radius: 5px; padding: 0 6px; margin-inline-start: 4px; }

/* ---- facts (job header) ---- */
dl.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr) max-content minmax(0, 1fr); gap: 4px 14px; margin: 0; }
dl.facts dt { color: var(--muted); font-size: 13px; } dl.facts dd { margin: 0; overflow-wrap: anywhere; }
dl.facts dd.wide { grid-column: span 3; }

/* ---- live account grid (9 accounts: 5 per row on desktop) ---- */
.acct-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.acct { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fcfcfd; min-width: 0; }
.acct .row1 { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.acct .name { font-weight: 700; font-size: 14px; }
.acct .elapsed { color: var(--muted); font-size: 12px; }
.acct .state { margin-top: 4px; }
.acct .detail { color: var(--muted); font-size: 12px; margin-top: 2px; overflow-wrap: anywhere; min-height: 0; }
.acct.st-completed { border-color: #bfe3cd; } .acct.st-failed, .acct.st-interrupted { border-color: #f3c5c1; }

/* ---- tables ---- */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: start; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: #f8f9fb; font-weight: 600; color: #4b5563; white-space: nowrap; font-size: 12.5px; }
tbody tr:hover { background: #fafbfc; }
td.title { max-width: 560px; }
td.n, th.n { text-align: end; white-space: nowrap; }
table.results td.acc { font-weight: 700; white-space: nowrap; }
table.results td.price { font-weight: 700; font-size: 14px; }
.sub { display: block; color: var(--muted); font-size: 11.5px; font-weight: 400; white-space: nowrap; }

/* ---- results groups ---- */
.group { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
.group:first-of-type { border-top: 0; margin-top: 0; }
.group h2 { margin: 0 0 2px; } .group.primary h2 { color: var(--ok); }
.group .meta { margin: 0 0 8px; }

.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumbs img { height: 110px; border: 1px solid var(--line); border-radius: 8px; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 5px 0; border-bottom: 1px dashed var(--line); }
ul.plain li:last-child { border-bottom: 0; }
.log { max-height: 220px; overflow-y: auto; }

/* ---- wide screens ---- */
@media (min-width: 1600px) {
  body { font-size: 14.5px; }
  .acct-grid { grid-template-columns: repeat(9, minmax(0, 1fr)); }
}

/* ---- tablets / small laptops ---- */
@media (max-width: 1100px) {
  .cols { grid-template-columns: minmax(0, 1fr); }
  dl.facts { grid-template-columns: max-content minmax(0, 1fr); }
  dl.facts dd.wide { grid-column: auto; }
}

/* ---- phones: true mobile layout ---- */
@media (max-width: 760px) {
  body { font-size: 15px; }
  .top { height: auto; flex-wrap: wrap; gap: 6px; padding: 8px 12px; }
  .brand { font-size: 15px; }
  nav { width: 100%; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; order: 3; }
  .logout { order: 2; } .logout button { width: auto; min-height: 32px; }
  input[type=text], input[type=password] { min-height: 44px; font-size: 16px; }
  .card.login { margin-top: 16px; }
  nav a { text-align: center; padding: 8px 2px; font-size: 13.5px; background: #22262e; }
  .banner { padding: 6px 12px; }
  main { padding: 10px 10px 4px; }
  .card { padding: 12px; border-radius: 10px; }
  .card.narrow { max-width: none; }
  h1 { font-size: 17px; }
  label { font-size: 14px; }
  input[type=url], input[type=number], input[type=file] { min-height: 44px; font-size: 16px; }
  button, .button { width: 100%; min-height: 44px; }
  dl.facts { grid-template-columns: 1fr; gap: 0; }
  dl.facts dt { margin-top: 8px; font-size: 12.5px; }
  .acct-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .acct { padding: 8px; }
  .thumbs img { height: 90px; }
  .tag, .best, .sub, th, .small, .hint { font-size: 12.5px; }
  .pill { font-size: 12.5px; padding: 2px 10px; }
  nav a { min-height: 40px; display: flex; align-items: center; justify-content: center; }
  input.qtyin { min-height: 40px; width: 96px; font-size: 16px; }

  /* tables -> stacked cards (every cell keeps its label) */
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack thead { display: none; }
  table.stack tr { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin-bottom: 8px; background: #fff; }
  table.stack td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: 12px; text-align: start; }
  table.stack td::before { content: attr(data-label); color: var(--muted); font-size: 13px; font-weight: 400; flex: none; }
  table.stack td.title { max-width: none; display: block; }
  table.stack td.title::before { display: block; }
  table.stack td.n { text-align: end; }
  .tablewrap { overflow: visible; }

  /* result card: account + comparable price + status on top, the rest in a 2-column grid */
  table.results tr { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; }
  table.results td { display: flex; flex-direction: column; justify-content: flex-start; gap: 0; padding: 2px 0; }
  table.results td::before { font-size: 12px; }
  table.results td.acc { grid-column: 1; font-size: 16px; flex-direction: row; align-items: center; gap: 6px; flex-wrap: wrap; }
  table.results td.acc::before, table.results td.status::before, table.results td.price::before { display: none; }
  table.results td.status { grid-column: 2; grid-row: 1; align-items: flex-end; justify-content: center; }
  table.results td.price { grid-column: 1 / -1; font-size: 20px; border-bottom: 1px solid var(--line); padding-bottom: 6px; margin-bottom: 4px; }
  table.results td.price .sub { font-size: 12px; }
  .sub { white-space: normal; }
}
