/* Qoupe UI. Ported from the reference design "Qoupe - واجهة رفع وتتبع الروايات". */
:root {
  --bg: #EEF0F6;
  --card: #FFFFFF;
  --soft: #F7F8FB;
  --ink: #171A2E;
  --ink-2: #3D4259;
  --muted: #5A607A;
  --line: #DFE2EC;
  --line-2: #C9CEDF;
  --primary: #4A3AD1;
  --primary-ink: #3A2CB8;
  --primary-soft: #ECEAFB;
  --amber: #C77700;
  --amber-ink: #8A4B00;
  --amber-soft: #FFF1D6;
  --green: #1F8A5F;
  --green-ink: #17694A;
  --green-soft: #DDF3E8;
  --red: #A8261D;
  --red-soft: #FBE4E1;
}

* { box-sizing: border-box }
html { -webkit-text-size-adjust: 100% }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
}
h1, h2, h3, p { margin: 0 }
a { color: var(--primary-ink) }
a:hover { color: #251A8A }
button, input, select, textarea { font: inherit; color: inherit }
[hidden] { display: none !important }
.display { font-family: 'Zain', 'IBM Plex Sans Arabic', sans-serif; font-weight: 800 }
.h1 { font-size: 26px; line-height: 1.3 }
.h2 { font-size: 22px; line-height: 1.3 }
.muted { color: var(--muted) }
.small { font-size: 13px }
.tiny { font-size: 12px }
.ltr { direction: ltr; text-align: right; unicode-bidi: plaintext }
.clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0 }
.row { display: flex; align-items: center; gap: 10px }
.row.between { justify-content: space-between }
.row.wrap { flex-wrap: wrap }
.stack { display: flex; flex-direction: column; gap: 16px }
.grow { flex-grow: 1; min-width: 0 }

/* layout */
.shell { max-width: 480px; margin: 0 auto; padding: 16px }
.shell.wide { max-width: 1120px }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 24px; overflow: hidden }
.card-head { padding: 18px 24px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px }
.card-body { padding: 24px; display: flex; flex-direction: column; gap: 16px }
.view { animation: qp-rise .35s ease-out both }

.brand { display: flex; align-items: center; gap: 10px }
.brand-mark { width: 38px; height: 38px; border-radius: 12px; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0 }
.brand-name { font-size: 20px; line-height: 1.1 }
.chip { font-size: 12px; font-weight: 600; padding: 6px 10px; border-radius: 999px; background: var(--bg); color: var(--ink-2); white-space: nowrap }
.chip.outline { background: transparent; border: 1px solid var(--line) }

/* form */
.label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px }
.in { width: 100%; height: 46px; padding: 0 14px; border: 1.5px solid var(--line-2); border-radius: 12px; font-size: 15px; background: #fff }
textarea.in { height: auto; padding: 10px 14px; resize: vertical }
.in:focus, .btn:focus-visible, .opt:focus-visible { outline: 3px solid #C9C3F5; outline-offset: 1px; border-color: var(--primary) }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px }
.opts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px }
.opt { height: 46px; border-radius: 12px; font-size: 15px; font-weight: 600; cursor: pointer; background: #fff; color: var(--ink); border: 1.5px solid var(--line-2) }
.opt[aria-pressed="true"] { background: var(--primary); color: #fff; border-color: var(--primary) }

.drop { position: relative; display: flex; align-items: center; gap: 14px; padding: 18px; border: 1.5px dashed #9AA1BC; border-radius: 16px; background: var(--soft); cursor: pointer }
.drop:focus-within { outline: 3px solid #C9C3F5; outline-offset: 1px }
.drop.has-file { border-style: solid; border-color: var(--primary); background: var(--primary-soft) }
.drop input { position: absolute; opacity: 0; width: 1px; height: 1px }
.drop-icon { width: 44px; height: 44px; border-radius: 12px; background: #fff; border: 1px solid var(--line); color: var(--primary); display: flex; align-items: center; justify-content: center; flex-shrink: 0 }
.drop-title { display: block; font-size: 15px; font-weight: 600 }

.btn { height: 48px; padding: 0 20px; border: 0; border-radius: 12px; background: var(--primary); color: #fff; font-size: 15px; font-weight: 700; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; white-space: nowrap }
.btn:hover { color: #fff }
.btn.big { height: 52px; border-radius: 14px; font-size: 16px; width: 100% }
.btn.ghost { background: #fff; color: var(--primary-ink); border: 1.5px solid var(--primary) }
.btn.ghost:hover { color: var(--primary-ink) }
.btn.danger { background: var(--red) }
.btn.danger-ghost { background: #fff; color: var(--red); border: 1.5px solid var(--red) }
.btn.neutral { background: #fff; color: var(--ink); border: 1.5px solid var(--line-2); font-weight: 600 }
.btn.text { background: transparent; color: var(--primary-ink); font-size: 14px; font-weight: 600; padding: 0 12px }
.btn.sm { height: 36px; padding: 0 12px; border-radius: 10px; font-size: 12px }
.btn.md { height: 44px; padding: 0 14px; font-size: 13px }
.btn:disabled { opacity: .55; cursor: default }

.alert { padding: 10px 14px; border-radius: 12px; background: var(--red-soft); color: var(--red); font-size: 13px; font-weight: 500 }
.alert.inline { padding: 0; background: transparent; margin-top: 8px }
.note { padding: 12px 14px; border-radius: 14px; background: var(--soft); border: 1px solid var(--line); font-size: 13px; color: var(--ink-2) }
.note.ok { background: var(--green-soft); border-color: transparent; color: var(--green-ink) }

/* status tracker */
.linkbox { display: flex; align-items: center; gap: 10px; padding: 8px 14px 8px 8px; border: 1px solid var(--line); border-radius: 14px; background: var(--soft) }
.hero { border-radius: 18px; padding: 20px; display: flex; align-items: center; gap: 18px }
.hero.is-pending { background: #FFF4DC }
.hero.is-analyzing { background: var(--primary-soft) }
.hero.is-ready { background: var(--green-soft) }
.hero.is-rejected { background: var(--red-soft) }
.hero-art { position: relative; width: 84px; height: 104px; flex-shrink: 0 }
.sheet { position: absolute; top: 4px; right: 4px; width: 76px; height: 96px; padding: 14px 11px; background: #fff; border: 1.5px solid #B9BFD6; border-radius: 9px; display: flex; flex-direction: column; gap: 7px }
.sheet span { display: block; height: 4px; border-radius: 2px; background: #9AA1BC }
.sheet span:nth-child(1) { width: 100% } .sheet span:nth-child(2) { width: 82% } .sheet span:nth-child(3) { width: 94% }
.sheet span:nth-child(4) { width: 70% } .sheet span:nth-child(5) { width: 90% } .sheet span:nth-child(6) { width: 58% }
.hero.is-pending .sheet span { opacity: .45 }
.hero.is-analyzing .sheet span { animation: qp-shimmer 1.6s ease-in-out infinite }
.hero.is-analyzing .sheet span:nth-child(2) { animation-delay: .15s }
.hero.is-analyzing .sheet span:nth-child(3) { animation-delay: .3s }
.hero.is-analyzing .sheet span:nth-child(4) { animation-delay: .45s }
.hero.is-analyzing .sheet span:nth-child(5) { animation-delay: .6s }
.hero.is-analyzing .sheet span:nth-child(6) { animation-delay: .75s }
.badge { position: absolute; bottom: 0; left: 0; width: 36px; height: 36px; border-radius: 50%; color: #fff; display: none; align-items: center; justify-content: center }
.badge.clock { background: var(--amber) } .badge.tick { background: var(--green-ink) } .badge.cross { background: var(--red) }
.badge.clock::before { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--amber); animation: qp-pulse 1.8s ease-out infinite }
.loupe { position: absolute; top: 2px; left: 40px; width: 42px; height: 42px; color: var(--primary); display: none; animation: qp-scan 4.2s ease-in-out infinite }
.hero.is-pending .badge.clock, .hero.is-ready .badge.tick, .hero.is-rejected .badge.cross { display: flex }
.hero.is-analyzing .loupe { display: block }
.hand { transform-origin: 12px 12px; animation: qp-spin 6s linear infinite }
.tick path { stroke-dasharray: 24; stroke-dashoffset: 24; animation: qp-draw .5s .15s ease-out forwards }
.eyebrow { font-size: 12px; font-weight: 700 }
.is-pending .eyebrow { color: var(--amber-ink) } .is-analyzing .eyebrow { color: var(--primary-ink) }
.is-ready .eyebrow { color: var(--green-ink) } .is-rejected .eyebrow { color: var(--red) }
.hero-title { margin-top: 4px; font-size: 21px; line-height: 1.35 }
.hero-desc { margin-top: 6px; font-size: 13px; line-height: 1.7; color: var(--ink-2); overflow-wrap: anywhere }

.steps { margin: 0; padding: 0; list-style: none }
.step { display: flex; gap: 14px }
.rail { display: flex; flex-direction: column; align-items: center }
.knot { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; position: relative; flex-shrink: 0; border: 2px solid var(--line-2); background: #fff; color: #fff }
.knot svg { display: none }
.knot.is-done { background: var(--primary); border-color: var(--primary) }
.knot.is-done .i-tick, .knot.is-fail .i-cross { display: block }
.knot.is-active { border-color: var(--primary) }
.knot.is-hold { border-color: var(--amber) }
.knot.is-fail { background: var(--red); border-color: var(--red) }
.knot.is-active::before, .knot.is-hold::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--primary) }
.knot.is-hold::before { background: var(--amber) }
.knot.is-active::after, .knot.is-hold::after { content: ""; position: absolute; inset: -2px; border-radius: 50%; border: 2px solid var(--primary); animation: qp-pulse 1.8s ease-out infinite }
.knot.is-hold::after { border-color: var(--amber) }
.thread { width: 2px; flex-grow: 1; min-height: 16px; margin: 4px 0; background: var(--line) }
.thread.is-done { background: var(--primary) }
.thread.is-active { background: repeating-linear-gradient(var(--primary) 0 6px, transparent 6px 12px); background-size: 2px 12px; animation: qp-flow .6s linear infinite }
.step:last-child .thread { display: none }
.step-body { flex-grow: 1; min-width: 0; padding-bottom: 16px }
.step-title { font-size: 15px; font-weight: 600; line-height: 28px }
.step-title.is-wait { color: var(--muted) }

.out { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 16px }
.out-icon { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; background: var(--primary-soft); color: var(--primary-ink) }
.out-icon.amber { background: var(--amber-soft); color: var(--amber-ink) }
.live { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted) }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex-shrink: 0; animation: qp-blink 1.6s ease-in-out infinite }
.live.off i { background: var(--line-2); animation: none }

/* admin */
.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--bg); color: var(--ink-2); white-space: nowrap }
.pill.is-pending { background: var(--amber-soft); color: var(--amber-ink) }
.pill.is-analyzing { background: var(--primary-soft); color: var(--primary-ink) }
.pill.is-ready { background: var(--green-soft); color: var(--green-ink) }
.pill.is-rejected { background: var(--red-soft); color: var(--red) }
.stat { min-width: 108px; padding: 10px 14px; border-radius: 14px }
.stat b { display: block; font-family: 'Zain', sans-serif; font-weight: 800; font-size: 24px; line-height: 1.1 }
.stat span { font-size: 12px; font-weight: 600 }
.stat.pending { background: var(--amber-soft); color: var(--amber-ink) }
.stat.analyzing { background: var(--primary-soft); color: var(--primary-ink) }
.stat.ready { background: var(--green-soft); color: var(--green-ink) }
.section-title { font-size: 16px; font-weight: 700; margin-top: 12px }
.box { border: 1.5px solid var(--line-2); border-radius: 18px; padding: 20px; display: flex; flex-direction: column; gap: 16px }
.box.pending { border-color: var(--amber) }
.box.analyzing { border-color: var(--primary) }
.box.empty { border-style: dashed; padding: 28px; text-align: center; gap: 4px }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 20px }
.facts dt { font-size: 12px; color: var(--muted) }
.facts dd { margin: 0; font-size: 14px; font-weight: 600; overflow-wrap: anywhere }
.cmd { padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--soft); font-size: 13px; line-height: 1.7 }
.table { border: 1px solid var(--line); border-radius: 18px; overflow: hidden }
.tr { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 1.1fr) minmax(0, 1.5fr) minmax(0, 1.9fr); gap: 16px; align-items: center; padding: 14px 20px; border-top: 1px solid var(--line); font-size: 13px }
.tr.head { border-top: 0; background: var(--soft); font-size: 12px; font-weight: 700; color: var(--muted); padding: 12px 20px }
.tr .name { font-size: 15px; font-weight: 700 }
.indet { margin-top: 8px; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden }
.indet i { display: block; width: 40%; height: 100%; border-radius: 2px; background: var(--primary); animation: qp-slide 1.5s ease-in-out infinite }
.login { max-width: 420px; margin: 8vh auto 0 }
.row > .in.grow { width: auto; flex: 1 1 240px }
.tr .row { margin-top: 6px }

@media (max-width: 720px) {
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)) }
  .tr { grid-template-columns: 1fr; gap: 8px }
  .tr.head { display: none }
  .card-head { flex-wrap: wrap }
  .card-body { padding: 18px }
  .stat { min-width: 0; flex: 1 }
}

@keyframes qp-rise { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: none } }
@keyframes qp-pulse { 0% { transform: scale(1); opacity: .6 } 100% { transform: scale(2.1); opacity: 0 } }
@keyframes qp-shimmer { 0%, 100% { opacity: .35 } 50% { opacity: 1 } }
@keyframes qp-scan { 0%, 100% { transform: translate(0, 0) } 25% { transform: translate(-32px, 12px) } 50% { transform: translate(-4px, 32px) } 75% { transform: translate(-34px, 50px) } }
@keyframes qp-spin { to { transform: rotate(360deg) } }
@keyframes qp-draw { to { stroke-dashoffset: 0 } }
@keyframes qp-flow { to { background-position: 0 12px } }
@keyframes qp-blink { 0%, 100% { opacity: 1 } 50% { opacity: .35 } }
@keyframes qp-slide { from { transform: translateX(110%) } to { transform: translateX(-260%) } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important }
  .tick path { stroke-dashoffset: 0 }
}
