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

:root {
  --bg-top: #f9fafb;
  --bg-bottom: #eef2f7;
  --surface: rgba(255, 255, 255, 0.84);
  --surface-strong: rgba(255, 255, 255, 0.96);
  --surface-soft: rgba(255, 255, 255, 0.62);
  --text: #0f172a;
  --text-soft: #667085;
  --text-faint: #98a2b3;
  --line: rgba(15, 23, 42, 0.08);
  --line-strong: rgba(15, 23, 42, 0.12);
  --primary: #111827;
  --primary-press: #030712;
  --secondary-text: #0f172a;
  --success-bg: #ecfdf3;
  --success-text: #027a48;
  --error-bg: #fef3f2;
  --error-text: #b42318;
  --info-bg: #eff4ff;
  --info-text: #3538cd;
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 18px;
  --radius-sm: 14px;
  --shadow-lg: 0 20px 60px rgba(15, 23, 42, 0.10);
  --shadow-md: 0 10px 30px rgba(15, 23, 42, 0.08);
  --shadow-sm: 0 4px 14px rgba(15, 23, 42, 0.06);
  --blur: saturate(180%) blur(28px);
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: 20px 16px 28px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top center, rgba(255,255,255,0.95) 0%, rgba(244,247,251,0.92) 24%, rgba(236,241,247,1) 100%);
}

.app-shell {
  width: 100%;
}

.container {
  max-width: 620px;
  margin: 0 auto;
}

.hero-card,
.content-card {
  position: relative;
  background: var(--surface);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid rgba(255,255,255,0.65);
  box-shadow: var(--shadow-lg);
}

.hero-card {
  border-radius: 32px;
  padding: 16px;
  margin-bottom: 18px;
}

.content-card {
  border-radius: 28px;
  padding: 20px;
  margin-bottom: 14px;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 12px;
}

.compact-top-bar {
  min-height: 36px;
}

.top-spacer {
  flex: 1;
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(255,255,255,0.74);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.lang-btn {
  width: auto;
  min-height: 30px;
  margin: 0;
  padding: 0 11px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  box-shadow: none;
  transform: scale(1);
  transition: transform 0.08s ease, background 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
}

.lang-btn:active {
  transform: scale(0.94);
}

.lang-btn.active {
  background: var(--surface-strong);
  color: var(--text);
  box-shadow: 0 2px 7px rgba(15, 23, 42, 0.10);
}

.scan-panel {
  padding: 16px;
  border-radius: 24px;
  background: rgba(255,255,255,0.56);
  border: 1px solid rgba(255,255,255,0.66);
}

.field,
.grid-two {
  margin-bottom: 14px;
}

.grid-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
  color: #475467;
}

input,
select,
button {
  width: 100%;
  min-height: 56px;
  font-size: 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.9);
  color: var(--text);
  transition: transform 0.12s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

input,
select {
  padding: 0 16px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.75);
}

select {
  appearance: none;
  -webkit-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #667085 50%),
    linear-gradient(135deg, #667085 50%, transparent 50%);
  background-position:
    calc(100% - 22px) calc(50% - 3px),
    calc(100% - 16px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 38px;
}

input::placeholder {
  color: var(--text-faint);
}

input:focus,
select:focus,
button:focus {
  outline: none;
  border-color: rgba(17, 24, 39, 0.18);
  box-shadow: 0 0 0 4px rgba(17, 24, 39, 0.05);
}

button {
  border: none;
  font-weight: 700;
}

button:active {
  transform: scale(0.985);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
}

.btn-primary {
  background: linear-gradient(180deg, #1f2937 0%, #111827 100%);
  color: #fff;
  box-shadow: 0 10px 24px rgba(17, 24, 39, 0.18);
}

.btn-primary:active {
  background: var(--primary-press);
}

.btn-secondary {
  background: rgba(255,255,255,0.78);
  color: var(--secondary-text);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

#reader {
  width: 100%;
  display: none;
  overflow: hidden;
  margin-bottom: 14px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #f6f8fb 0%, #eef2f6 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.7);
}

#reader video {
  border-radius: 22px;
}

.barcode-row {
  display: grid;
  grid-template-columns: 1fr 58px;
  gap: 10px;
  align-items: stretch;
  margin-bottom: 14px;
}

.scan-icon-btn {
  min-height: 56px;
  padding: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  background: linear-gradient(180deg, #1f2937 0%, #111827 100%);
  color: #fff;
  box-shadow: 0 10px 24px rgba(17, 24, 39, 0.16);
}

.scan-icon-btn.active {
  background: linear-gradient(180deg, #dc2626 0%, #b91c1c 100%);
}

.scan-icon-btn svg {
  width: 22px;
  height: 22px;
  display: block;
}

.scan-icon-btn path {
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.media-card {
  margin-bottom: 16px;
  padding: 16px;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.62);
}

.media-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.media-title-wrap {
  min-width: 0;
}

.media-title {
  margin-bottom: 2px;
}

.media-subtitle {
  font-size: 12px;
  color: var(--text-soft);
}

.photo-add-btn {
  width: auto;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(255,255,255,0.92);
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

.photo-add-btn svg {
  width: 18px;
  height: 18px;
  display: block;
}

.photo-add-btn path {
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  fill: none;
}

.hidden-file-input {
  display: none;
}

.gallery-shell {
  width: 100%;
}

.image-card {
  position: relative;
  min-height: 250px;
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,0.88) 0%, rgba(246,248,251,0.95) 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.7);
}

.gallery-track {
  position: relative;
  min-height: 250px;
}

.preview {
  width: 100%;
  height: 250px;
  object-fit: contain;
  display: none;
  background: transparent;
}

.image-empty-action {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
  color: var(--text-soft);
  font-size: 15px;
  font-weight: 700;
  background: transparent;
  border: none;
  box-shadow: none;
  min-height: 100%;
}

.image-empty-action svg {
  width: 28px;
  height: 28px;
  display: block;
}

.image-empty-action path {
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  fill: none;
}

.image-delete-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 50;
  width: 42px;
  min-width: 42px;
  max-width: 42px;
  height: 42px;
  min-height: 42px;
  padding: 0;
  margin: 0;
  display: none;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.20);
  pointer-events: auto;
}

.image-add-overlay-btn {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 30;
  width: 42px;
  min-height: 42px;
  height: 42px;
  padding: 0;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.20);
}

.image-add-overlay-btn svg {
  width: 18px;
  height: 18px;
  display: block;
}

.image-add-overlay-btn path {
  stroke: currentColor;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.image-delete-btn svg {
  width: 18px;
  height: 18px;
  display: block;
  pointer-events: none;
}

.image-delete-btn path {
  stroke: currentColor;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  min-width: 40px;
  max-width: 40px;
  min-height: 40px;
  height: 40px;
  padding: 0;
  border-radius: 999px;
  background: rgba(255,255,255,0.78);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.gallery-nav svg {
  width: 18px;
  height: 18px;
  display: block;
}

.gallery-nav path {
  stroke: currentColor;
  stroke-width: 2.3;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.gallery-prev {
  left: 10px;
}

.gallery-next {
  right: 10px;
}

.gallery-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding-top: 12px;
  min-height: 18px;
}

.gallery-dot {
  width: 7px;
  min-width: 7px;
  max-width: 7px;
  height: 7px;
  min-height: 7px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.14);
  transition: transform 0.15s ease, background 0.15s ease;
  padding: 0;
  margin: 0;
}

.gallery-dot.active {
  background: rgba(15, 23, 42, 0.65);
  transform: scale(1.2);
}

.btn-save {
  margin-top: 4px;
}

.status-wrap {
  position: sticky;
  bottom: 10px;
  z-index: 20;
}

.status {
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  padding: 14px 18px;
  border-radius: 18px;
  text-align: center;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.01em;
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: 1px solid rgba(255,255,255,0.72);
  box-shadow: var(--shadow-md);
  transition: 0.2s ease;
}

.status.info {
  background: rgba(239, 244, 255, 0.86);
  color: var(--info-text);
}

.status.success {
  background: rgba(236, 253, 243, 0.90);
  color: var(--success-text);
}

.status.error {
  background: rgba(254, 243, 242, 0.92);
  color: var(--error-text);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.38);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.modal-backdrop.open {
  display: flex;
}

.modal-card {
  width: 100%;
  max-width: 420px;
  padding: 20px;
  border-radius: 24px;
  background: rgba(255,255,255,0.96);
  border: 1px solid rgba(255,255,255,0.72);
  box-shadow: var(--shadow-lg);
}

.modal-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
}

.modal-text {
  font-size: 14px;
  color: var(--text-soft);
  line-height: 1.5;
  margin-bottom: 14px;
}

.modal-input {
  width: 100%;
  margin-bottom: 14px;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.modal-btn {
  min-height: 52px;
}

body[dir="rtl"] {
  text-align: right;
}

body[dir="rtl"] .top-bar {
  flex-direction: row-reverse;
}

body[dir="rtl"] .action-row,
body[dir="rtl"] .grid-two,
body[dir="rtl"] .modal-actions {
  direction: rtl;
}

body[dir="rtl"] .barcode-row {
  grid-template-columns: 58px 1fr;
}

body[dir="rtl"] .barcode-row input {
  order: 2;
}

body[dir="rtl"] .barcode-row .scan-icon-btn {
  order: 1;
}

body[dir="rtl"] .media-top {
  flex-direction: row-reverse;
}

body[dir="rtl"] .gallery-prev {
  left: auto;
  right: 10px;
}

body[dir="rtl"] .gallery-next {
  right: auto;
  left: 10px;
}

body[dir="rtl"] .image-delete-btn {
  right: auto;
  left: 10px;
}

body[dir="rtl"] .image-add-overlay-btn {
  left: auto;
  right: 10px;
}

body[dir="rtl"] select {
  background-position:
    18px calc(50% - 3px),
    24px calc(50% - 3px);
  padding-left: 38px;
  padding-right: 16px;
}

@media (max-width: 640px) {
  body {
    padding: 14px 12px 24px;
  }

  .hero-card,
  .content-card {
    border-radius: 24px;
  }

  .hero-card {
    padding: 14px;
  }

  .content-card {
    padding: 18px;
  }

  .media-top {
    align-items: flex-start;
  }
}

@media (max-width: 520px) {
  .grid-two,
  .action-row,
  .modal-actions {
    grid-template-columns: 1fr;
  }

  .media-top {
    flex-direction: column;
    align-items: stretch;
  }

  .photo-add-btn {
    width: 100%;
    justify-content: center;
  }

  body[dir="rtl"] .media-top {
    flex-direction: column;
    align-items: stretch;
  }
}