:root {
  --bg: #f1f1f1;
  --card: #fff;
  --ink: #303030;
  --muted: #616161;
  --line: #e3e3e3;
  --line-strong: #8a8a8a;
  --fill: #f7f7f7;
  --dark: #303030;
  --ok-bg: #cdfee1;
  --ok-ink: #0c5132;
  --info-bg: #e0f0ff;
  --info-ink: #00527c;
  --warn-bg: #fff1c2;
  --warn-ink: #5e4200;
  --bad-bg: #fee9e8;
  --bad-ink: #8e1f0b;
  --radius: 12px;
  --shadow: 0 1px 0 rgba(26, 26, 26, 0.07), 0 0 0 1px rgba(26, 26, 26, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 13px/1.5 Inter, 'Segoe UI', Tahoma, 'Noto Sans Arabic', sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

h1 {
  font-size: 20px;
  font-weight: 700;
}

h2 {
  margin-block: 20px 8px;
  font-size: 14px;
  font-weight: 650;
}

h4 {
  margin-block-start: 6px;
  font-size: 13px;
  font-weight: 650;
}

.page {
  max-width: 1000px;
  margin: 0 auto;
  padding: 20px 20px 80px;
}

.page--wide {
  max-width: 1180px;
}

.muted {
  color: var(--muted);
  font-weight: 400;
}

.row,
.between,
.top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.row--end {
  justify-content: flex-end;
  flex-wrap: nowrap;
}

.between,
.top {
  justify-content: space-between;
}

/* The title and its save buttons stay in reach while a long editor scrolls. */
.top {
  position: sticky;
  inset-block-start: 0;
  z-index: 5;
  margin: -20px -20px 8px;
  padding: 14px 20px 10px;
  background: var(--bg);
}

.between > h2 {
  margin-block-end: 8px;
}

.stack {
  display: grid;
  gap: 6px;
}

.grid {
  display: grid;
  gap: 12px;
  align-items: start;
}

.spinner {
  width: 28px;
  height: 28px;
  margin: 120px auto;
  border: 3px solid var(--line);
  border-top-color: var(--dark);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- buttons, badges, switch ---------- */

.btn {
  padding: 6px 12px;
  border: 0;
  border-radius: 8px;
  background: var(--card);
  box-shadow: inset 0 -1px 0 #b5b5b5, inset 0 0 0 1px rgba(0, 0, 0, 0.1), inset 0 0.5px 0 1.5px #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 550;
  white-space: nowrap;
  cursor: pointer;
}

.btn:hover {
  background: #fafafa;
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn--primary {
  background: linear-gradient(180deg, #3c3c3c, #262626);
  box-shadow: inset 0 -1px 0 1px rgba(0, 0, 0, 0.8), inset 0 2px 0 rgba(255, 255, 255, 0.2);
  color: #fff;
}

.btn--primary:hover {
  background: #1a1a1a;
}

.btn--danger {
  background: #c70a24;
  box-shadow: none;
  color: #fff;
}

.btn--plain,
.btn--plain-danger,
.btn--icon {
  background: none;
  box-shadow: none;
}

.btn--plain:hover,
.btn--plain-danger:hover,
.btn--icon:hover {
  background: rgba(0, 0, 0, 0.06);
}

.btn--plain-danger {
  color: var(--bad-ink);
}

.btn--icon {
  min-width: 28px;
  padding: 4px 6px;
  font-size: 14px;
  line-height: 1.3;
}

.btn:focus-visible,
.sw:focus-visible,
.in:focus-visible,
.type:focus-visible,
.tabs button:focus-visible {
  outline: 2px solid #005bd3;
  outline-offset: 1px;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 550;
  white-space: nowrap;
}

.badge--ok {
  background: var(--ok-bg);
  color: var(--ok-ink);
}

.badge--off {
  background: #e3e3e3;
  color: var(--muted);
}

.badge--info {
  background: var(--info-bg);
  color: var(--info-ink);
}

.badge--warn {
  background: var(--warn-bg);
  color: var(--warn-ink);
}

.sw {
  position: relative;
  flex: none;
  width: 32px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: #b5b5b5;
  cursor: pointer;
  transition: background-color 0.15s;
}

.sw::after {
  content: '';
  position: absolute;
  inset-block-start: 3px;
  inset-inline-start: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: inset-inline-start 0.15s;
}

.sw.is-on {
  background: var(--dark);
}

.sw.is-on::after {
  inset-inline-start: 15px;
}

.banner {
  margin-block-end: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.banner--ok {
  background: var(--ok-bg);
  color: var(--ok-ink);
}

.banner--info {
  background: var(--info-bg);
  color: var(--info-ink);
}

.banner--warn {
  background: var(--warn-bg);
  color: var(--warn-ink);
}

.banner--bad {
  background: var(--bad-bg);
  color: var(--bad-ink);
}

/* ---------- cards, home ---------- */

.card {
  padding: 16px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.card--flush {
  padding: 0;
  overflow: hidden;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.tile {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.tile span {
  color: var(--muted);
  font-weight: 550;
  text-decoration: underline dotted #ccc;
  text-underline-offset: 4px;
}

.tile b {
  font-size: 20px;
  font-weight: 650;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 8px;
  border-block-end: 1px solid var(--line);
}

.tabs button,
.pv__tabs button {
  padding: 5px 12px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 550;
  cursor: pointer;
}

.tabs button:hover {
  background: rgba(0, 0, 0, 0.05);
}

.tabs button.is-on,
.pv__tabs button.is-on {
  background: rgba(0, 0, 0, 0.08);
  color: var(--ink);
}

.tabs i {
  font-style: normal;
  opacity: 0.7;
}

.list {
  width: 100%;
  border-collapse: collapse;
}

.list th {
  padding: 8px 16px;
  border-block-end: 1px solid var(--line);
  background: var(--fill);
  color: var(--muted);
  font-size: 12px;
  font-weight: 550;
  text-align: start;
}

.list td {
  padding: 10px 16px;
  border-block-end: 1px solid #ebebeb;
  vertical-align: middle;
}

.list tr:last-child td {
  border-block-end: 0;
}

.list tbody tr {
  cursor: pointer;
}

.list tbody tr:hover {
  background: var(--fill);
}

.list td b {
  display: block;
  font-weight: 650;
}

.list td small {
  color: var(--muted);
  font-size: 12px;
}

.empty {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 48px 16px;
  color: var(--muted);
}

.empty b {
  color: var(--ink);
  font-size: 14px;
}

/* ---------- choose a type ---------- */

.types {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.type {
  display: grid;
  gap: 6px;
  padding: 12px 12px 16px;
  border: 0;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  color: var(--muted);
  font: inherit;
  text-align: start;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.15s;
}

.type:hover {
  box-shadow: 0 0 0 2px var(--dark);
  transform: translateY(-2px);
}

.type b {
  color: var(--ink);
  font-size: 14px;
}

/* A small drawing of the offer: three stacked bars, varied per type. */
.type__art {
  display: grid;
  align-content: center;
  gap: 6px;
  height: 120px;
  margin-block-end: 6px;
  padding: 0 28px;
  border-radius: 8px;
  background: #f3f0ea;
}

.type__art i {
  position: relative;
  height: 22px;
  border-radius: 6px;
  background: #fff;
  box-shadow: inset 0 0 0 1px #d9cfc0;
}

.type__art i::before {
  content: '';
  position: absolute;
  inset-block-start: 7px;
  inset-inline-start: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  box-shadow: 0 0 0 1.5px #c6a179;
}

.type__art i::after {
  content: '';
  position: absolute;
  inset-block-start: 8px;
  inset-inline: 24px 40%;
  height: 6px;
  border-radius: 3px;
  background: #ddd;
}

.type__art i:nth-child(2) {
  box-shadow: inset 0 0 0 2px #c6a179;
}

.type__art i:nth-child(2)::before {
  background: #c6a179;
}

.type__art--free i:nth-child(3),
.type__art--fixed i:nth-child(3) {
  display: none;
}

.type__art--free i::after {
  background: linear-gradient(to left, #ddd 55%, transparent 55% 62%, #c6a179 62%);
}

.type__art--fixed i::after {
  inset-inline: 24px 55%;
}

.type__art--bundle {
  grid-template-columns: 1fr 1fr 1fr;
}

.type__art--bundle i {
  height: 56px;
}

.type__art--bundle i::before,
.type__art--bundle i::after {
  display: none;
}

.type__art--chart {
  gap: 0;
}

.type__art--chart i {
  height: 20px;
  border-radius: 0;
  background: repeating-linear-gradient(to left, #fff 0 24%, #d9cfc0 24% 25%);
}

.type__art--chart i:first-child {
  background: #25344e;
  box-shadow: none;
}

.type__art--chart i::before,
.type__art--chart i::after {
  display: none;
}

/* ---------- editor ---------- */

.editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 16px;
  align-items: start;
}

.editor__main {
  display: grid;
  gap: 12px;
}

.editor__side {
  position: sticky;
  inset-block-start: 64px;
}

.fold {
  padding: 0;
}

.fold__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
  cursor: pointer;
}

.fold__head b {
  font-size: 14px;
  font-weight: 650;
}

.fold__body {
  display: grid;
  gap: 12px;
  padding: 4px 16px 16px;
}

.chev {
  width: 8px;
  height: 8px;
  margin-inline: 4px;
  border: solid var(--muted);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  transition: transform 0.15s;
}

.fold.is-open > .fold__head .chev {
  transform: rotate(-135deg);
}

.add {
  padding: 12px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: none;
  color: var(--ink);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.add:hover {
  background: rgba(0, 0, 0, 0.04);
}

.f {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.f__label {
  font-weight: 450;
}

.f__hint {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.in {
  width: 100%;
  min-width: 0;
  height: 32px;
  padding: 5px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fdfdfd;
  color: var(--ink);
  font: inherit;
}

.in:disabled {
  border-color: var(--line);
  background: var(--fill);
  color: var(--muted);
}

.ck {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
}

.ck input {
  flex: none;
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  accent-color: var(--dark);
}

.color {
  display: flex;
  gap: 6px;
}

.color input[type='color'] {
  flex: none;
  width: 32px;
  height: 32px;
  padding: 2px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.picked {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.picked > div {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
}

.picked > div + div {
  border-block-start: 1px solid var(--line);
}

.picked > div > span:nth-child(2) {
  flex: 1;
  min-width: 0;
}

.layouts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.layout {
  display: grid;
  gap: 4px;
  align-content: center;
  height: 64px;
  padding: 10px 14px;
  border: 0;
  border-radius: 8px;
  background: var(--fill);
  box-shadow: inset 0 0 0 1px var(--line);
  cursor: pointer;
}

.layout.is-on {
  box-shadow: inset 0 0 0 2px var(--dark);
}

.layout i {
  height: 9px;
  border-radius: 3px;
  background: #c9c9c9;
}

.layout.is-on i {
  background: var(--dark);
}

.layout--horizontal {
  grid-template-columns: 1fr 1fr 1fr;
}

.layout--horizontal i {
  height: 34px;
}

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

.layout--grid i {
  height: 16px;
}

.layout--compact i {
  height: 3px;
  margin-block: 3px;
}

.sheet {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--fill);
}

.sheet .between {
  align-items: end;
  flex-wrap: nowrap;
}

.sheet .between .f {
  flex: 1;
}

.sheet__row {
  display: grid;
  gap: 4px;
  align-items: center;
}

.sheet__row--head .in {
  font-weight: 650;
}

/* ---------- preview ---------- */

.pv {
  display: grid;
  gap: 12px;
}

.pv__stage {
  padding: 16px 14px;
  border-radius: 8px;
  background: #f6f3ee;
}

.pv__stage .sw-deals {
  margin: 0;
}

.pv__stage .sw-bt {
  margin: 0;
}

.pv__thumb {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  background: linear-gradient(135deg, #e7e0d4, #cfc4b2);
}

.pv__chart {
  display: grid;
  gap: 10px;
}

.pv__tabs {
  display: flex;
  gap: 4px;
}

.pv__chart table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  text-align: center;
}

.pv__chart th {
  padding: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 650;
}

.pv__chart td {
  padding: 8px;
  border: 1px solid var(--line);
}

@media (max-width: 900px) {
  .editor {
    grid-template-columns: minmax(0, 1fr);
  }

  .editor__side {
    position: static;
    order: -1;
  }

  .tiles,
  .types {
    grid-template-columns: 1fr 1fr;
  }

  .list th:nth-child(2),
  .list td:nth-child(2),
  .list th:nth-child(3),
  .list td:nth-child(3) {
    display: none;
  }
}
