/* ==========================================================================
   PharmaStock - Universal Color System (UCS)
   Seed: brand purple #5E2B97  |  accent amber #F3A11C
   Tonal steps follow a perceptual light->dark scale, WCAG AA compliant pairs.
   ========================================================================== */

:root {
  /* ---- brand ramp ---- */
  --brand-50: #f7f2fc;
  --brand-100: #ede1f7;
  --brand-200: #d9c2ee;
  --brand-300: #bd95df;
  --brand-400: #9e6aca;
  --brand-500: #7e45b0;
  --brand-600: #5e2b97;
  --brand-700: #4b2179;
  --brand-800: #38185a;
  --brand-900: #260f3d;
  --brand-950: #170826;

  /* ---- accent ramp ---- */
  --accent-100: #fff2d8;
  --accent-200: #ffe1ab;
  --accent-300: #ffd27a;
  --accent-400: #fdc24a;
  --accent-500: #f3a11c;
  --accent-600: #d98708;
  --accent-700: #a96405;

  /* ---- semantic ---- */
  --success-500: #0f9d6f;
  --success-100: #dcf5ec;
  --warning-500: #e08b00;
  --warning-100: #fdf0d5;
  --danger-500: #d92d4b;
  --danger-100: #fde4e8;
  --info-500: #2f7bd9;
  --info-100: #e2eefc;

  /* ---- neutral ---- */
  --n-0: #ffffff;
  --n-25: #fbfafd;
  --n-50: #f6f4f9;
  --n-100: #eeeaf5;
  --n-200: #e0dbe9;
  --n-300: #c8c1d6;
  --n-400: #9c93b0;
  --n-500: #6f6684;
  --n-600: #544c66;
  --n-700: #3d374a;
  --n-800: #282332;
  --n-900: #16121f;

  --bg: var(--n-50);
  --bg-elev: var(--n-0);
  --bg-sunken: var(--n-100);
  --text: var(--n-900);
  --text-muted: var(--n-500);
  --border: var(--n-200);
  --primary: var(--brand-600);
  --primary-ink: #ffffff;
  --accent: var(--accent-500);

  --grad-brand: linear-gradient(135deg, #6d35a0 0%, #5e2b97 45%, #3f1b6b 100%);
  --grad-cta: linear-gradient(120deg, var(--brand-600) 0%, var(--brand-500) 52%, var(--accent-500) 130%);
  --grad-accent: linear-gradient(135deg, var(--accent-400), var(--accent-600));

  --shadow-1: 0 1px 2px rgba(38, 15, 61, 0.06), 0 2px 8px rgba(38, 15, 61, 0.06);
  --shadow-2: 0 6px 18px rgba(38, 15, 61, 0.12), 0 2px 6px rgba(38, 15, 61, 0.06);
  --shadow-3: 0 18px 48px rgba(38, 15, 61, 0.22);
  --glow-accent: 0 0 0 4px rgba(243, 161, 28, 0.18);
  --glow-brand: 0 0 0 4px rgba(94, 43, 151, 0.16);

  --r-xs: 10px;
  --r-sm: 14px;
  --r-md: 20px;
  --r-lg: 26px;
  --r-xl: 34px;
  --r-pill: 999px;

  --pad: 16px;
  --appbar-h: 62px;
  --tabbar-h: 68px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

[data-theme="dark"] {
  --bg: #120b1d;
  --bg-elev: #1c1230;
  --bg-sunken: #0d0715;
  --text: #f4f0fa;
  --text-muted: #a99ec0;
  --border: #2e2344;
  --primary: var(--brand-400);
  --primary-ink: #12071f;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-2: 0 8px 22px rgba(0, 0, 0, 0.55);
  --shadow-3: 0 20px 50px rgba(0, 0, 0, 0.7);
  --success-100: #0c3b2c;
  --warning-100: #40300c;
  --danger-100: #43131d;
  --info-100: #122944;
  --brand-50: #1a1030;
  --brand-100: #241640;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme]) {
    --bg: #120b1d;
    --bg-elev: #1c1230;
    --bg-sunken: #0d0715;
    --text: #f4f0fa;
    --text-muted: #a99ec0;
    --border: #2e2344;
    --primary: var(--brand-400);
    --primary-ink: #12071f;
    --brand-50: #1a1030;
    --brand-100: #241640;
    --success-100: #0c3b2c;
    --warning-100: #40300c;
    --danger-100: #43131d;
    --info-100: #122944;
  }
}

/* -------------------------------- reset -------------------------------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Cairo", "Segoe UI", Tahoma, "Noto Naskh Arabic", system-ui, sans-serif;
  background: var(--bg-sunken);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
button { cursor: pointer; border: 0; background: none; }
ul, ol { list-style: none; margin: 0; padding: 0; }
h1, h2, h3, h4, p { margin: 0; }
img { display: block; max-width: 100%; }
:focus-visible { outline: 3px solid var(--accent-500); outline-offset: 2px; border-radius: 6px; }

/* ------------------------------ app frame ------------------------------ */
#phone-frame {
  position: relative;
  width: 100%;
  max-width: 460px;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: var(--bg);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15), 0 30px 80px rgba(0, 0, 0, 0.4);
}
@media (min-width: 500px) {
  body { background: #0a0612 radial-gradient(circle at 50% 0%, #2a1245, #0a0612 65%); padding: 14px 0; }
  #phone-frame { height: calc(100dvh - 28px); border-radius: 30px; }
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  background: var(--bg);
}
.screen.is-active { display: flex; }
.screen-center { align-items: center; justify-content: center; padding: 26px; text-align: center; }

/* ================================ SPLASH =============================== */
.splash-bg {
  position: absolute;
  inset: 0;
  background: var(--grad-brand);
  overflow: hidden;
}
.splash-bg::before,
.splash-bg::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(2px);
}
.splash-bg::before {
  width: 340px; height: 340px;
  background: radial-gradient(circle at 35% 35%, rgba(243, 161, 28, 0.9), rgba(243, 161, 28, 0) 68%);
  top: -90px; left: -110px;
  animation: drift 9s ease-in-out infinite alternate;
}
.splash-bg::after {
  width: 420px; height: 420px;
  background: radial-gradient(circle at 60% 40%, rgba(189, 149, 223, 0.55), rgba(94, 43, 151, 0) 70%);
  bottom: -160px; right: -140px;
  animation: drift 11s ease-in-out infinite alternate-reverse;
}
@keyframes drift { from { transform: translate3d(0,0,0) scale(1); } to { transform: translate3d(24px,20px,0) scale(1.12); } }

.splash-inner {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  height: 100%;
  justify-content: center;
  color: #fff;
}
.splash-logo {
  width: 150px; height: 150px;
  border-radius: 34px;
  box-shadow: 0 22px 46px rgba(0, 0, 0, 0.35);
  animation: pop 0.9s var(--ease-bounce) both;
  background: #fff;
}
@keyframes pop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.splash-title { font-size: 30px; letter-spacing: 0.5px; font-weight: 800; animation: rise 0.7s 0.15s var(--ease) both; }
.splash-sub { color: rgba(255, 255, 255, 0.82); font-size: 14px; animation: rise 0.7s 0.25s var(--ease) both; }
.splash-foot { position: absolute; bottom: 34px; color: rgba(255, 255, 255, 0.7); font-size: 13px; letter-spacing: 0.3px; }
@keyframes rise { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }

.orbital-loader { display: flex; gap: 8px; margin-top: 18px; }
.orbital-loader span {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent-400);
  animation: bounce 1.1s infinite;
}
.orbital-loader span:nth-child(2) { animation-delay: 0.15s; background: #fff; }
.orbital-loader span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 0%, 100% { transform: translateY(0); opacity: 0.6; } 50% { transform: translateY(-10px); opacity: 1; } }

/* ============================ DESKTOP BLOCK ============================ */
.block-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 26px 22px;
  max-width: 380px;
  box-shadow: var(--shadow-3);
}
.block-card h2 { font-size: 20px; margin-bottom: 10px; color: var(--primary); }
.block-card p { color: var(--text-muted); font-size: 14px; line-height: 1.9; }
.block-steps { display: grid; gap: 8px; margin: 18px 0; text-align: right; }
.block-steps span {
  background: var(--brand-50);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  font-size: 13px;
}
.phone-glyph {
  width: 96px; height: 168px;
  margin: 0 auto 18px;
  border: 3px solid var(--brand-600);
  border-radius: 22px;
  position: relative;
  background: var(--brand-50);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.phone-glyph-notch {
  position: absolute; top: 8px; width: 34px; height: 6px; border-radius: 4px; background: var(--brand-600);
}
.phone-glyph-robot { width: 74px; height: 74px; }

/* ================================ LOGIN ================================ */
.login-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(120% 60% at 50% 0%, rgba(94, 43, 151, 0.35), transparent 70%),
    radial-gradient(90% 50% at 50% 100%, rgba(243, 161, 28, 0.22), transparent 70%);
  pointer-events: none;
}
.login-card {
  position: relative;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  animation: rise 0.6s var(--ease) both;
}
.login-robot { width: 132px; height: 132px; margin-bottom: -6px; }
.login-logo { width: 62px; height: 62px; border-radius: 16px; box-shadow: var(--shadow-2); }
.login-title { font-size: 20px; font-weight: 800; }
.login-sub { font-size: 13px; color: var(--text-muted); line-height: 1.8; }
#login-form { width: 100%; display: grid; gap: 12px; margin-top: 8px; }

.field { display: grid; gap: 6px; width: 100%; text-align: right; }
.field-label { font-size: 12px; color: var(--text-muted); padding-inline-start: 4px; }
.field-wrap { position: relative; display: block; }
.field input,
.field-wrap input,
input[type="text"], input[type="password"] {
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--r-sm);
  border: 1.5px solid var(--border);
  background: var(--bg-elev);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field input:focus, .field-wrap input:focus {
  border-color: var(--primary);
  box-shadow: var(--glow-brand);
  outline: none;
}
.peek {
  position: absolute;
  inset-inline-start: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  padding: 6px;
}
.login-error {
  color: var(--danger-500);
  font-size: 13px;
  background: var(--danger-100);
  border-radius: var(--r-xs);
  padding: 9px 12px;
  text-align: right;
}
.login-note {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.9;
  display: flex;
  gap: 6px;
  align-items: flex-start;
  text-align: right;
  margin-top: 4px;
}
.login-note svg { flex: none; margin-top: 3px; color: var(--success-500); }

/* =============================== BUTTONS =============================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: var(--r-sm);
  font-weight: 700;
  font-size: 14px;
  transition: transform 0.12s var(--ease), box-shadow 0.2s, background 0.2s, opacity 0.2s;
  border: 1.5px solid transparent;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; pointer-events: none; }
.btn-block { width: 100%; }
.btn-lg { padding: 16px; font-size: 15.5px; border-radius: var(--r-md); }
.btn-primary {
  background: var(--grad-cta);
  color: #fff;
  box-shadow: 0 10px 24px rgba(94, 43, 151, 0.32);
}
.btn-primary:active { box-shadow: 0 4px 12px rgba(94, 43, 151, 0.3); }
.btn-soft { background: var(--brand-50); color: var(--primary); border-color: var(--border); }
[data-theme="dark"] .btn-soft { background: var(--brand-100); }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-danger-soft { background: var(--danger-100); color: var(--danger-500); }
.btn-accent { background: var(--grad-accent); color: #3a2200; }

.btn-label { transition: opacity 0.2s; }
.btn-spinner {
  width: 17px; height: 17px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  display: none;
  animation: spin 0.7s linear infinite;
}
.btn.is-loading .btn-spinner { display: block; }
.btn.is-loading .btn-label { opacity: 0.75; }
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 12px;
  color: var(--text-muted);
  background: var(--bg-sunken);
  transition: background 0.2s, color 0.2s;
}
.icon-btn:active { background: var(--brand-100); color: var(--primary); }

/* ============================== APP SHELL ============================== */
#app { background: var(--bg); }
.appbar {
  height: var(--appbar-h);
  padding: 0 14px;
  padding-top: env(safe-area-inset-top);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--grad-brand);
  color: #fff;
  box-shadow: var(--shadow-2);
  z-index: 5;
  position: relative;
}
.appbar::after {
  content: "";
  position: absolute; inset-inline: 0; bottom: -1px; height: 3px;
  background: var(--grad-accent);
  opacity: 0.9;
}
.appbar-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.appbar-brand img { width: 38px; height: 38px; border-radius: 11px; background: #fff; padding: 2px; }
.appbar-text { display: grid; line-height: 1.15; min-width: 0; }
.appbar-text strong { font-size: 15.5px; letter-spacing: 0.3px; }
.appbar-text span { font-size: 11.5px; color: rgba(255, 255, 255, 0.78); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar-actions { display: flex; gap: 8px; }
.appbar .icon-btn { background: rgba(255, 255, 255, 0.16); color: #fff; }
.appbar .icon-btn:active { background: rgba(255, 255, 255, 0.3); }

.appbody {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 14px calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom));
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}
.view { display: none; animation: viewIn 0.34s var(--ease) both; }
.view.is-active { display: block; }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.tabbar {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--bg-elev);
  background: color-mix(in srgb, var(--bg-elev) 90%, transparent);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  z-index: 6;
}
.tab {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 3px;
  color: var(--text-muted);
  font-size: 11px;
  position: relative;
  transition: color 0.2s;
}
.tab svg { transition: transform 0.25s var(--ease-bounce); }
.tab.is-active { color: var(--primary); }
.tab.is-active svg { transform: translateY(-2px) scale(1.08); }
.tab.is-active::before {
  content: "";
  position: absolute; top: 0; width: 30px; height: 3.5px;
  background: var(--grad-accent);
  border-radius: 0 0 6px 6px;
}

/* ========================= LIVE SYNC COMPONENTS ======================= */
.live-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  border-radius: var(--r-pill);
  background: var(--bg-elev);
  border: 1.5px solid var(--border);
  margin-bottom: 12px;
  font-size: 12.5px;
  font-weight: 700;
  box-shadow: var(--shadow-1);
  transition: background 0.3s, border-color 0.3s;
}
.live-bar .live-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-bar .live-code {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  background: var(--bg-sunken);
  padding: 3px 9px;
  border-radius: var(--r-pill);
  letter-spacing: 1px;
}
.live-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--n-400);
  flex: none;
}
.live-bar.live { border-color: var(--success-500); background: var(--success-100); color: var(--success-500); }
.live-bar.live .live-dot { background: var(--success-500); animation: pulse 1.4s infinite; }
.live-bar.closed { border-color: var(--brand-500); background: var(--brand-50); color: var(--primary); }
.live-bar.offline { border-color: var(--warning-500); background: var(--warning-100); color: var(--warning-500); }
.live-bar.offline .live-dot { background: var(--warning-500); animation: pulse 1s infinite; }

#view-scan.is-idle .camera-stage,
#view-scan.is-idle .shots,
#view-scan.is-idle .capture-bar,
#view-scan.is-idle .scan-actions { display: none; }
#view-scan.is-live .waiting,
#view-scan.is-closed .waiting { display: none; }

.waiting {
  display: grid;
  justify-items: center;
  gap: 12px;
  text-align: center;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 34px 22px;
  box-shadow: var(--shadow-1);
  animation: rise 0.4s var(--ease) both;
}
.waiting-robot { width: 128px; height: 128px; }
.waiting h3 { font-size: 18px; font-weight: 800; }
.waiting p { color: var(--text-muted); font-size: 13px; line-height: 1.9; max-width: 320px; }
.waiting-steps { display: grid; gap: 8px; width: 100%; max-width: 320px; margin-top: 4px; }
.waiting-steps li {
  display: flex; align-items: center; gap: 10px;
  background: var(--brand-50);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  font-size: 12.5px;
  text-align: right;
}
.waiting-steps b {
  width: 22px; height: 22px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--grad-cta);
  color: #fff;
  font-size: 12px;
}
.waiting-pulse { font-size: 11.5px; color: var(--text-muted); animation: blinksoft 1.8s infinite; }
@keyframes blinksoft { 0%, 100% { opacity: 0.45; } 50% { opacity: 1; } }

.sync-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 13px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  font-weight: 700;
  margin-bottom: 12px;
}
.sync-banner.is-live { background: var(--success-100); color: var(--success-500); }
.sync-banner.is-live .live-dot { background: var(--success-500); animation: pulse 1.4s infinite; }
.sync-banner.is-closed { background: var(--brand-50); color: var(--primary); }
.sync-banner.is-closed .live-dot { background: var(--primary); }
.sync-banner > span:last-child { flex: 1; min-width: 0; }

.item.is-new { animation: newItem 0.9s var(--ease) both; }
@keyframes newItem {
  0% { opacity: 0; transform: translateY(-8px) scale(0.98); box-shadow: 0 0 0 0 rgba(243, 161, 28, 0.6); }
  35% { box-shadow: 0 0 0 6px rgba(243, 161, 28, 0.22); }
  100% { opacity: 1; transform: none; box-shadow: var(--shadow-1); }
}

/* =============================== CAMERA =============================== */
.camera-stage {
  position: relative;
  aspect-ratio: 3 / 4;
  max-height: 58dvh;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: #0a0612;
  box-shadow: var(--shadow-2);
  isolation: isolate;
}
#camera { width: 100%; height: 100%; object-fit: cover; display: block; background: #0a0612; }
#camera.mirror { transform: scaleX(-1); }
.cam-placeholder {
  position: absolute; inset: 0;
  display: grid; place-items: center; align-content: center; gap: 12px;
  color: #cfc4e2; text-align: center; padding: 20px;
  background: radial-gradient(circle at 50% 40%, #2a1245, #0a0612);
}
.cam-placeholder-robot { width: 108px; height: 108px; opacity: 0.95; }
.cam-placeholder p { font-size: 13px; }

.scan-frame { position: absolute; inset: 26px 22px; pointer-events: none; }
.corner {
  position: absolute; width: 30px; height: 30px;
  border: 3.5px solid var(--accent-400);
  filter: drop-shadow(0 0 6px rgba(243, 161, 28, 0.6));
}
.corner.tl { top: 0; inset-inline-start: 0; border-right: 0; border-bottom: 0; border-radius: 12px 0 0 0; }
.corner.tr { top: 0; inset-inline-end: 0; border-left: 0; border-bottom: 0; border-radius: 0 12px 0 0; }
.corner.bl { bottom: 0; inset-inline-start: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 12px; }
.corner.br { bottom: 0; inset-inline-end: 0; border-left: 0; border-top: 0; border-radius: 0 0 12px 0; }
.scan-line {
  position: absolute; inset-inline: 0; height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent-400), transparent);
  box-shadow: 0 0 18px 4px rgba(243, 161, 28, 0.55);
  animation: sweep 2.6s var(--ease) infinite;
}
@keyframes sweep { 0% { top: 2%; opacity: 0; } 12% { opacity: 1; } 88% { opacity: 1; } 100% { top: 97%; opacity: 0; } }
.scan-grid {
  position: absolute; inset: 0;
  background-image: linear-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: radial-gradient(circle at 50% 50%, #000 55%, transparent 100%);
}

.cam-hud { position: absolute; top: 12px; inset-inline: 12px; display: flex; gap: 8px; }
.hud-chip {
  background: rgba(10, 6, 18, 0.55);
  color: #fff;
  backdrop-filter: blur(8px);
  border-radius: var(--r-pill);
  padding: 7px 13px;
  font-size: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
}
.hud-btn { font-weight: 700; }
.hud-btn.is-on { background: var(--accent-500); color: #2c1a00; border-color: transparent; }
.cam-tip {
  position: absolute; bottom: 12px; inset-inline: 12px;
  background: rgba(10, 6, 18, 0.6);
  color: #f0eaf8;
  font-size: 12px;
  text-align: center;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: opacity 0.4s;
}

.shots { display: flex; gap: 9px; overflow-x: auto; padding: 12px 2px 4px; min-height: 4px; }
.shots:empty { padding: 0; }
.shot {
  position: relative; flex: none;
  width: 62px; height: 62px;
  border-radius: 14px; overflow: hidden;
  border: 2px solid var(--accent-400);
  box-shadow: var(--shadow-1);
  animation: pop 0.35s var(--ease-bounce) both;
}
.shot img { width: 100%; height: 100%; object-fit: cover; }
.shot .shot-x {
  position: absolute; top: -1px; inset-inline-end: -1px;
  width: 21px; height: 21px; border-radius: 0 12px 0 12px;
  background: rgba(0, 0, 0, 0.65); color: #fff; font-size: 13px; line-height: 21px; text-align: center;
}
.shot .shot-n {
  position: absolute; bottom: 2px; inset-inline-end: 4px; font-size: 10px; color: #fff;
  text-shadow: 0 1px 3px #000;
}

.capture-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}
.cap-item { display: grid; justify-items: center; gap: 6px; }
.cap-item > span { font-size: 10.5px; color: var(--text-muted); white-space: nowrap; }
.shutter {
  justify-self: center;
  width: 82px; height: 82px;
  border-radius: 50%;
  background: var(--bg-elev);
  border: 4px solid var(--brand-200);
  display: grid; place-items: center;
  box-shadow: var(--shadow-2);
  transition: transform 0.12s var(--ease);
}
.shutter span {
  width: 62px; height: 62px; border-radius: 50%;
  background: var(--grad-cta);
  transition: transform 0.15s var(--ease);
  box-shadow: inset 0 2px 6px rgba(255, 255, 255, 0.35);
}
.shutter:active { transform: scale(0.94); }
.shutter:active span { transform: scale(0.9); }
.shutter.is-busy span { background: var(--grad-accent); }
.round-btn {
  width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--bg-sunken); color: var(--text-muted);
  border: 1.5px solid var(--border);
}
.round-btn:active { background: var(--brand-100); color: var(--primary); }

.scan-actions { margin-top: 14px; display: grid; gap: 8px; }
.hint { font-size: 12px; color: var(--text-muted); text-align: center; line-height: 1.8; }

.quick-row { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; justify-content: center; }
.chip-btn {
  padding: 8px 14px;
  border-radius: var(--r-pill);
  background: var(--bg-elev);
  border: 1.5px solid var(--border);
  font-size: 12.5px;
  color: var(--text-muted);
  transition: all 0.2s;
}
.chip-btn.is-active { background: var(--brand-600); color: #fff; border-color: transparent; }

/* =============================== REVIEW =============================== */
.session-head { display: grid; gap: 12px; margin-bottom: 12px; }
.session-title-block { background: var(--grad-brand); color: #fff; border-radius: var(--r-md); padding: 14px; box-shadow: var(--shadow-2); }
.field.inline { gap: 4px; }
.field.inline .field-label { color: rgba(255, 255, 255, 0.75); }
.field.inline input {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #fff;
  padding: 10px 12px;
  border-radius: var(--r-xs);
}
.field.inline input::placeholder { color: rgba(255, 255, 255, 0.5); }
.field.inline input:focus { background: rgba(255, 255, 255, 0.22); border-color: var(--accent-400); box-shadow: none; }
.session-meta { display: block; margin-top: 8px; font-size: 11.5px; color: rgba(255, 255, 255, 0.75); }

.stat-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.stat {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 11px 8px;
  text-align: center;
  box-shadow: var(--shadow-1);
}
.stat b { display: block; font-size: 22px; color: var(--primary); font-weight: 800; }
.stat span { font-size: 11px; color: var(--text-muted); }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .btn { flex: 1 1 30%; font-size: 12.5px; padding: 10px 8px; }

.items { display: grid; gap: 10px; }
.item {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 13px;
  box-shadow: var(--shadow-1);
  position: relative;
  overflow: hidden;
}
/* only brand-new rows animate - updates never restart this */
.item.is-new { animation: pop 0.32s var(--ease) both; }

.item-quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.quick-chip {
  font-size: 11.5px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 4px 10px;
}
.quick-chip b { color: var(--primary); font-weight: 800; margin-inline-end: 4px; }

.item-details { margin-top: 10px; border-top: 1px dashed var(--border); padding-top: 9px; }
.item-details > summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  color: var(--primary);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.item-details > summary::-webkit-details-marker { display: none; }
.item-details > summary::before { content: "▾"; transition: transform 0.2s; display: inline-block; }
.item-details[open] > summary::before { transform: rotate(180deg); }
.spec-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  margin: 10px 0 2px;
  font-size: 12.5px;
}
.spec-grid dt { color: var(--text-muted); }
.spec-grid dd { margin: 0; font-weight: 700; word-break: break-word; text-align: start; }
.item::before {
  content: "";
  position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 4px;
  background: var(--grad-accent);
}
.item.low::before { background: var(--warning-500); }
.item-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.item-names { min-width: 0; flex: 1; }
.item-en { font-weight: 800; font-size: 15px; line-height: 1.4; }
.item-ar { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.item-en[contenteditable="true"], .item-ar[contenteditable="true"] {
  border-radius: 6px; padding: 2px 4px;
}
.item-en:focus, .item-ar:focus { background: var(--brand-50); outline: none; }
.item-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.tag { font-size: 10.5px; padding: 3px 9px; border-radius: var(--r-pill); background: var(--brand-50); color: var(--primary); font-weight: 700; }
.tag.cat { background: var(--info-100); color: var(--info-500); }
.tag.warn { background: var(--warning-100); color: var(--warning-500); }
.tag.ok { background: var(--success-100); color: var(--success-500); }
.item-note { font-size: 11.5px; color: var(--text-muted); margin-top: 8px; line-height: 1.7; }
.item-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.stepper { display: flex; align-items: center; gap: 6px; background: var(--bg-sunken); border-radius: var(--r-pill); padding: 4px; }
.stepper button {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--bg-elev); font-size: 19px; font-weight: 800; color: var(--primary);
  box-shadow: var(--shadow-1);
}
.stepper input {
  width: 52px; text-align: center; border: 0; background: transparent; font-weight: 800; font-size: 16px;
}
.conf { flex: 1; }
.conf-bar { height: 6px; border-radius: 4px; background: var(--bg-sunken); overflow: hidden; margin-top: 5px; }
.conf-bar i { display: block; height: 100%; border-radius: 4px; background: var(--grad-accent); transition: width 0.5s var(--ease); }
.conf small { font-size: 10px; color: var(--text-muted); }
.del-btn { color: var(--danger-500); padding: 6px; border-radius: 10px; }
.del-btn:active { background: var(--danger-100); }

.empty { display: grid; place-items: center; gap: 8px; text-align: center; padding: 40px 22px; color: var(--text-muted); }
.empty-robot { width: 96px; height: 96px; opacity: 0.9; }
.empty h3 { color: var(--text); font-size: 16px; }
.empty p { font-size: 13px; line-height: 1.9; max-width: 300px; }
.empty .btn { margin-top: 8px; }

/* ============================== SESSIONS ============================== */
.section-title { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.section-title h2 { font-size: 17px; font-weight: 800; }
.pill { background: var(--brand-600); color: #fff; font-size: 11.5px; padding: 3px 11px; border-radius: var(--r-pill); font-weight: 700; }
.sessions { display: grid; gap: 10px; }
.session-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px;
  box-shadow: var(--shadow-1);
  display: grid;
  gap: 10px;
}
.session-card header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.session-card h3 { font-size: 15px; font-weight: 800; }
.session-card time { font-size: 11px; color: var(--text-muted); }
.session-card .mini-stats { display: flex; gap: 14px; font-size: 12px; color: var(--text-muted); }
.session-card .mini-stats b { color: var(--primary); }
.session-card .row { display: flex; gap: 8px; }
.session-card .row .btn { flex: 1; font-size: 12px; padding: 9px; }

/* ============================== SETTINGS ============================== */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 15px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-1);
  display: grid;
  gap: 10px;
}
.card-head { display: flex; align-items: center; gap: 12px; }
.card-robot { width: 46px; height: 46px; flex: none; }
.muted { color: var(--text-muted); font-size: 12.5px; line-height: 1.85; }
.kv { display: grid; gap: 6px; }
.kv-row { display: flex; justify-content: space-between; font-size: 12.5px; padding: 7px 10px; background: var(--bg-sunken); border-radius: var(--r-xs); }
.kv-row b { color: var(--primary); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13.5px; position: relative; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch i {
  width: 46px; height: 27px; border-radius: var(--r-pill);
  background: var(--n-300); position: relative; transition: background 0.25s; flex: none;
}
.switch i::after {
  content: ""; position: absolute; top: 3px; inset-inline-start: 3px;
  width: 21px; height: 21px; border-radius: 50%; background: #fff;
  transition: transform 0.25s var(--ease); box-shadow: var(--shadow-1);
}
.switch input:checked + i { background: var(--brand-600); }
.switch input:checked + i::after { transform: translateX(-19px); }
html[dir="ltr"] .switch input:checked + i::after { transform: translateX(19px); }
.about { text-align: center; justify-items: center; }
.about img { border-radius: 16px; box-shadow: var(--shadow-1); }

/* ============================= OVERLAYS ============================= */
.overlay {
  position: absolute; inset: 0; z-index: 40;
  display: grid; place-items: center;
  background: rgba(12, 6, 22, 0.92);
  backdrop-filter: blur(14px);
  color: #fff;
  padding: 24px;
  animation: fade 0.25s both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.overlay-inner { width: 100%; max-width: 320px; text-align: center; display: grid; gap: 14px; justify-items: center; }
.scan-robot { width: 168px; height: 168px; }
.overlay h3 { font-size: 17px; font-weight: 800; }
.steps { display: grid; gap: 8px; width: 100%; }
.steps li {
  display: flex; align-items: center; gap: 9px;
  font-size: 12.5px; color: rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--r-xs); padding: 9px 12px;
  transition: all 0.3s;
  text-align: right;
}
.steps li::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; background: rgba(255, 255, 255, 0.3); flex: none;
}
.steps li.is-doing { color: #fff; background: rgba(243, 161, 28, 0.16); }
.steps li.is-doing::before { background: var(--accent-500); animation: pulse 1s infinite; }
.steps li.is-done { color: var(--success-500); }
.steps li.is-done::before { background: var(--success-500); }
@keyframes pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.6); opacity: 0.5; } }
.progress { width: 100%; height: 7px; border-radius: 5px; background: rgba(255, 255, 255, 0.14); overflow: hidden; }
.progress span { display: block; height: 100%; width: 0%; background: var(--grad-accent); transition: width 0.6s var(--ease); }

.modal { position: absolute; inset: 0; z-index: 50; display: grid; place-items: end center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(10, 5, 20, 0.6); backdrop-filter: blur(4px); animation: fade 0.2s both; }
.modal-card {
  position: relative;
  width: 100%;
  background: var(--bg-elev);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-3);
  animation: sheetUp 0.32s var(--ease) both;
  display: grid; gap: 12px;
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
.modal-card h3 { font-size: 17px; font-weight: 800; }
.modal-card input, .modal-card select {
  width: 100%; padding: 13px 14px; border-radius: var(--r-sm);
  border: 1.5px solid var(--border); background: var(--bg);
}
.modal-actions { display: flex; gap: 9px; }
.modal-actions .btn { flex: 1; }
.form-grid { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.form-grid .full { grid-column: 1 / -1; }

.lightbox { position: absolute; inset: 0; z-index: 60; background: rgba(0, 0, 0, 0.94); display: grid; place-items: center; padding: 16px; }
.lightbox img { max-height: 88%; border-radius: var(--r-md); }

.toast-host {
  position: absolute; inset-inline: 0; bottom: calc(var(--tabbar-h) + 18px);
  display: grid; gap: 8px; justify-items: center; z-index: 70; pointer-events: none; padding: 0 18px;
}
.toast {
  background: var(--n-900); color: #fff; font-size: 12.5px;
  padding: 11px 16px; border-radius: var(--r-pill);
  box-shadow: var(--shadow-3);
  animation: toastIn 0.3s var(--ease-bounce) both;
  max-width: 100%;
}
.toast.ok { background: var(--success-500); }
.toast.err { background: var(--danger-500); }
.toast.warn { background: var(--warning-500); color: #2b1a00; }
@keyframes toastIn { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ================================ ROBOT ================================ */
.robot { width: 100%; height: 100%; overflow: visible; }
.robot .r-float { animation: floaty 3.6s ease-in-out infinite; transform-origin: 100px 120px; }
@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.robot .r-head { fill: var(--brand-600); }
.robot .r-visor { fill: #1a0f2c; }
.robot .r-eye { fill: var(--accent-400); animation: blink 4.2s infinite; transform-box: fill-box; transform-origin: center; }
.robot .r-eye.e2 { animation-delay: 0.08s; }
@keyframes blink {
  0%, 92%, 100% { opacity: 1; transform: scaleY(1); }
  94%, 96% { opacity: 0.15; transform: scaleY(0.15); }
}
.robot .r-antenna { stroke: var(--brand-500); stroke-width: 5; stroke-linecap: round; }
.robot .r-tip { fill: var(--accent-500); transform-box: fill-box; transform-origin: center; }
@keyframes beacon { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.robot .r-tip { animation: beacon 1.6s ease-in-out infinite, tipPulse 1.6s ease-in-out infinite; }
@keyframes tipPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.35); } }
.robot .r-body { fill: #ffffff; stroke: var(--brand-600); stroke-width: 4; }
.robot .r-panel { fill: var(--brand-100); }
.robot .r-logo { fill: var(--brand-600); }
.robot .r-arm { stroke: var(--brand-400); stroke-width: 8; stroke-linecap: round; }
.robot .r-orbit { fill: none; stroke: var(--brand-400); stroke-width: 2; opacity: 0.35; stroke-dasharray: 6 10; animation: spin 12s linear infinite; transform-origin: 100px 110px; }
.robot .r-orbit.o2 { animation-direction: reverse; animation-duration: 18s; opacity: 0.22; }
.robot .r-beam { fill: var(--accent-400); opacity: 0.5; animation: beam 2.4s ease-in-out infinite; transform-box: fill-box; }
@keyframes beam { 0%, 100% { opacity: 0.15; transform: translateY(0); } 50% { opacity: 0.5; transform: translateY(46px); } }
.robot .r-badge { fill: var(--accent-500); }
.robot--scan .r-eye { animation: scanPulse 1.1s infinite; }
@keyframes scanPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
