:root {
  color-scheme: dark;
  --font-main: "Tajawal", "Segoe UI", sans-serif;
  --bg: #081116;
  --bg-elevated: rgba(15, 28, 35, 0.82);
  --bg-soft: rgba(255, 255, 255, 0.05);
  --surface: rgba(9, 18, 24, 0.78);
  --surface-strong: rgba(8, 14, 20, 0.95);
  --text: #f4f7f4;
  --text-soft: #aab8b5;
  --accent: #18b58a;
  --accent-strong: #0c8c68;
  --accent-warm: #ffb259;
  --danger: #d55353;
  --success: #14a44d;
  --border: rgba(255, 255, 255, 0.08);
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.33);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f7f5ef;
  --bg-elevated: rgba(255, 255, 255, 0.88);
  --bg-soft: rgba(7, 20, 28, 0.04);
  --surface: rgba(255, 255, 255, 0.94);
  --surface-strong: rgba(255, 255, 255, 0.98);
  --text: #1a262d;
  --text-soft: #61737d;
  --accent: #116f60;
  --accent-strong: #0b5a4f;
  --accent-warm: #db8a2f;
  --danger: #bc4646;
  --success: #177d43;
  --border: rgba(7, 20, 28, 0.08);
  --shadow: 0 18px 45px rgba(27, 44, 54, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-main);
  background:
    radial-gradient(circle at top left, rgba(24, 181, 138, 0.18), transparent 30%),
    radial-gradient(circle at bottom right, rgba(255, 178, 89, 0.16), transparent 34%),
    var(--bg);
  color: var(--text);
}

body {
  position: relative;
  padding: 16px 14px calc(96px + env(safe-area-inset-bottom));
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
  border: 0;
}

img {
  display: block;
  max-width: 100%;
}

.hidden {
  display: none !important;
}

.page-glow {
  position: fixed;
  inset: auto;
  width: 280px;
  height: 280px;
  border-radius: 999px;
  filter: blur(80px);
  opacity: 0.18;
  pointer-events: none;
  z-index: -1;
}

.page-glow-a {
  top: -90px;
  right: -40px;
  background: #18b58a;
}

.page-glow-b {
  left: -70px;
  bottom: 140px;
  background: #ffb259;
}

.screen {
  width: 100%;
}

.login-shell,
.content-shell {
  max-width: 1180px;
  margin: 0 auto;
}

.login-shell {
  display: grid;
  gap: 18px;
  padding-top: 20px;
}

.login-grid,
.stack-grid,
.summary-grid,
.list-grid,
.products-grid,
.orders-grid,
.stats-grid,
.top-products-list,
.checklist-grid,
.settings-grid {
  display: grid;
  gap: 14px;
}

.login-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.glass-card,
.overlay-card,
.ai-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-radius: 26px;
}

.glass-card,
.overlay-card,
.ai-panel,
.auth-card {
  padding: 18px;
}

.hero-card {
  overflow: hidden;
}

.hero-brand,
.brand-inline,
.card-title-row,
.action-row,
.upload-area,
.topbar,
.topbar-tools,
.selector-card,
.product-card,
.product-picker-card,
.order-card-header,
.metric-card,
.campaign-card,
.employee-card,
.return-card,
.ai-form {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hero-brand,
.brand-inline {
  justify-content: flex-start;
}

.brand-logo {
  width: 82px;
  height: 82px;
  border-radius: 22px;
  overflow: hidden;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.small-logo {
  width: 58px;
  height: 58px;
  border-radius: 18px;
}

.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 0.82rem;
  color: var(--accent-warm);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 6vw, 3.1rem);
}

h2 {
  font-size: clamp(1.35rem, 4vw, 1.85rem);
}

h3 {
  font-size: 1.05rem;
}

.subtle-text,
.subtle-line {
  color: var(--text-soft);
  line-height: 1.7;
}

.topbar {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: min(1180px, calc(100% - 28px));
  z-index: 40;
  justify-content: space-between;
  padding: 12px 16px;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: rgba(8, 17, 22, 0.82);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  display: none;
    
}

.content-shell {
  padding-top: 112px;
}

html[data-theme="light"] .topbar {
  background: rgba(255, 255, 255, 0.88);
}

.topbar-tools {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.soft-badge {
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 0.92rem;
  border: 1px solid var(--border);
}

.accent-badge {
  color: var(--accent);
}

.section-head,
.card-title-row {
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-head {
  gap: 12px;
  flex-wrap: wrap;
}

.section-head,
.card-title-row {
  display: flex;
  align-items: center;
}

.form-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.compact-form {
  align-items: end;
}

.field {
  display: grid;
  gap: 8px;
}

.field-button {
  align-content: end;
}

.field span {
  font-size: 0.92rem;
  color: var(--text-soft);
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  padding: 14px 16px;
  outline: none;
  transition: border-color 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: rgba(24, 181, 138, 0.55);
  transform: translateY(-1px);
}

.wide-field,
.full-width {
  grid-column: 1 / -1;
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 48px;
  padding: 0 18px;
  border-radius: 16px;
  transition: transform 0.2s ease, opacity 0.2s ease, background 0.2s ease;
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.nav-button:hover,
.upload-toggle:hover,
.selector-card:hover,
.product-picker-card:hover {
  transform: translateY(-1px);
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
}

.secondary-button {
  background: linear-gradient(135deg, rgba(255, 178, 89, 0.18), rgba(255, 178, 89, 0.34));
  color: var(--text);
  border: 1px solid rgba(255, 178, 89, 0.22);
}

.ghost-button {
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
}

.submit-button {
  min-height: 56px;
  font-weight: 700;
}

.upload-area {
  flex-wrap: wrap;
}

.upload-toggle {
  justify-content: center;
  min-height: 54px;
  padding: 0 18px;
  border-radius: 18px;
  font-weight: 700;
  color: #fff;
  min-width: 190px;
}

.upload-empty {
  background: linear-gradient(135deg, #cf4d4d, #912f2f);
}

.upload-filled {
  background: linear-gradient(135deg, #24c46d, #128345);
}

.image-preview-slot {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(120px, 160px));
  width: 100%;
}

.preview-card,
.image-frame {
  border-radius: 22px;
  overflow: hidden;
  background: var(--bg-soft);
  border: 1px solid var(--border);
}

.image-frame {
  aspect-ratio: 9 / 16;
}

.image-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.selector-card {
  justify-content: space-between;
  width: 100%;
  min-height: 88px;
  padding: 16px;
  border-radius: 22px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
}

.selector-thumb {
  width: 62px;
  height: 92px;
  border-radius: 18px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--surface-strong);
  border: 1px solid var(--border);
}

.selector-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.empty-thumb {
  position: relative;
}

.empty-thumb::before {
  content: "لا يوجد";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text-soft);
  font-size: 0.8rem;
}

.stats-grid {
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
}

.metric-card {
  justify-content: space-between;
  align-items: flex-start;
  flex-direction: column;
  padding: 16px;
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--border);
  min-height: 140px;
}

.metric-value {
  font-size: clamp(1.15rem, 5vw, 1.8rem);
  font-weight: 800;
}

.metric-caption {
  color: var(--text-soft);
  line-height: 1.6;
}

.top-products-list {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.rank-card,
.employee-card,
.campaign-card,
.product-card,
.product-picker-card,
.order-card,
.check-item {
  padding: 14px;
  border-radius: 22px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
}

.rank-card strong,
.employee-card strong,
.campaign-card strong,
.product-card strong,
.order-card strong {
  display: block;
  margin-bottom: 6px;
}

.products-grid,
.orders-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.products-grid {
  grid-template-columns: 1fr;
}

@media (max-width: 640px) {
  .product-card-compact {
    grid-template-columns: 60px minmax(0, 1fr);
  }

  .product-card-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .product-card-compact .image-frame {
    width: 60px;
  }
}

.product-card,
.product-picker-card {
  display: grid;
  gap: 12px;
}

.campaign-card {
  flex-direction: column;
  align-items: stretch;
}

.campaign-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.campaign-expense-list {
  display: grid;
  gap: 10px;
}

.campaign-expense-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.campaign-expense-details {
  display: grid;
  gap: 6px;
  color: var(--text-soft);
  font-size: 0.92rem;
}

.campaign-expense-details strong {
  display: inline;
  color: var(--text);
}

@media (max-width: 640px) {
  .campaign-expense-item,
  .campaign-card-header {
    flex-direction: column;
    align-items: stretch;
  }
}

.product-card-compact {
  grid-template-columns: 72px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
}

.product-card-body {
  min-width: 0;
}

.product-card-body strong {
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-card-actions {
  justify-content: flex-end;
  gap: 8px;
}

.product-card img,
.product-picker-card img {
  width: 100%;
  aspect-ratio: 9 / 16;
  border-radius: 18px;
  object-fit: cover;
}

.product-card-compact .image-frame {
  width: 72px;
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  overflow: hidden;
}

.product-card-compact .image-frame img {
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
}

.product-picker-card {
  cursor: pointer;
}

.order-card {
  display: grid;
  gap: 10px;
}

.order-card-header {
  justify-content: space-between;
  align-items: flex-start;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status-badge,
.tiny-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  border: 1px solid var(--border);
}

.status-active {
  background: rgba(24, 181, 138, 0.12);
  color: var(--accent);
}

.status-returned {
  background: rgba(213, 83, 83, 0.14);
  color: #ff8b8b;
}

.status-prepared {
  background: rgba(255, 178, 89, 0.16);
  color: var(--accent-warm);
}

.status-organic {
  background: rgba(17, 111, 96, 0.16);
}

.status-ad {
  background: rgba(255, 178, 89, 0.16);
}

.detail-list {
  display: grid;
  gap: 6px;
  color: var(--text-soft);
  font-size: 0.92rem;
}

.detail-list strong {
  display: inline;
  color: var(--text);
}

.preparing-order-card {
  gap: 14px;
}

.preparing-order-media {
  min-width: 124px;
  display: grid;
  gap: 8px;
  justify-items: end;
}

.preparing-order-media-label {
  font-size: 0.82rem;
  color: var(--text-soft);
}

.preparing-order-card .image-frame {
  width: 124px;
  aspect-ratio: 3 / 4;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-soft);
}

.preparing-order-card .image-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.order-items-list {
  display: grid;
  gap: 10px;
}

.order-item-row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 18px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
}

.order-item-row.is-empty {
  grid-template-columns: 1fr;
}

.order-item-row .image-frame {
  width: 56px;
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  overflow: hidden;
}

.order-item-row .image-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.order-item-body {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.order-item-body strong {
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.action-row {
  flex-wrap: wrap;
}

.summary-grid {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.summary-box {
  padding: 14px;
  border-radius: 20px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
}

.summary-box strong {
  display: block;
  margin-top: 6px;
  font-size: 1.02rem;
}

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.52);
  z-index: 40;
}

.overlay-card {
  width: min(100%, 720px);
  max-height: 88vh;
  overflow: auto;
}

.checklist-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.check-item input {
  width: 18px;
  height: 18px;
}

.calendar-summary-box,
.calendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.calendar-summary-box {
  padding: 14px;
  margin-bottom: 14px;
  border-radius: 20px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  flex-wrap: wrap;
}

.calendar-summary-box strong {
  display: block;
  margin-top: 6px;
}

.calendar-toolbar {
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.calendar-weekday,
.calendar-day {
  min-height: 48px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  text-align: center;
}

.calendar-weekday {
  color: var(--text-soft);
  font-size: 0.84rem;
}

.calendar-day {
  padding: 8px 4px;
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
}

.calendar-day.is-outside {
  opacity: 0.38;
}

.calendar-day.is-today {
  border-color: rgba(255, 178, 89, 0.4);
}

.calendar-day.is-selected,
.calendar-day.is-range {
  color: #fff;
}

.calendar-day.is-range {
  background: rgba(17, 111, 96, 0.18);
  border-color: rgba(17, 111, 96, 0.32);
}

.calendar-day.is-selected {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
}

.bottom-nav {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  border-radius: 24px;
  background: rgba(8, 14, 20, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 24;
  overflow-x: auto;
}

html[data-theme="light"] .bottom-nav {
  background: rgba(255, 255, 255, 0.92);
}

.nav-button {
  min-height: 56px;
  padding: 8px;
  border-radius: 18px;
  background: transparent;
  color: var(--text-soft);
  font-size: 0.82rem;
  white-space: nowrap;
}

.nav-button.is-active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
}

.ai-fab {
  position: fixed;
  left: 20px;
  bottom: calc(108px + env(safe-area-inset-bottom));
  width: 58px;
  height: 58px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent-warm), #d86a2c);
  color: #21160d;
  font-weight: 800;
  box-shadow: 0 18px 32px rgba(216, 106, 44, 0.35);
  z-index: 28;
}

.ai-panel {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(92px + env(safe-area-inset-bottom));
  max-width: 430px;
  margin-inline: auto;
  z-index: 32;
}

.ai-messages {
  display: grid;
  gap: 10px;
  max-height: 44vh;
  overflow: auto;
  margin: 14px 0;
}

.ai-message {
  padding: 12px 14px;
  border-radius: 18px;
  line-height: 1.7;
}

.ai-message.user {
  background: rgba(255, 178, 89, 0.18);
}

.ai-message.model {
  background: rgba(24, 181, 138, 0.13);
}

.ai-form input {
  flex: 1;
}

.toast-stack {
  position: fixed;
  top: 18px;
  left: 18px;
  display: grid;
  gap: 10px;
  z-index: 48;
}

.toast {
  min-width: 200px;
  max-width: 320px;
  padding: 12px 16px;
  border-radius: 18px;
  color: #fff;
  box-shadow: var(--shadow);
  animation: toast-in 0.25s ease;
}

.toast.success {
  background: linear-gradient(135deg, #1daf67, #0f7b46);
}

.toast.error {
  background: linear-gradient(135deg, #d55353, #8e3535);
}

.toast.info {
  background: linear-gradient(135deg, #116f60, #0b4e43);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 760px) {
  body {
    padding-inline: 22px;
  }

  .stack-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stack-grid > .glass-card:first-child,
  .stack-grid > .submit-button,
  .stack-grid > article:nth-child(2),
  .stack-grid > article:nth-child(3) {
    grid-column: 1 / -1;
  }

  .summary-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 759px) {
  .topbar {
    top: 10px;
    width: calc(100% - 20px);
    align-items: flex-start;
    flex-direction: column;
    padding: 12px 14px;
  }

  .content-shell {
    padding-top: 148px;
  }

  .bottom-nav {
    grid-template-columns: repeat(6, minmax(96px, 1fr));
  }

  .calendar-grid {
    gap: 6px;
  }

  .calendar-day,
  .calendar-weekday {
    min-height: 44px;
    font-size: 0.86rem;
  }
}
