:root {
  --rose: #d08979;
  --rose-dark: #b96f5e;
  --cream: #f6eedc;
  --paper: #efe7d0;
  --ink: #22220a;
  --ink-soft: #3a3a1c;
  --teal: #155f82;
  --teal-light: #2b6e8e;
  --line: rgba(34, 34, 10, 0.12);
  --danger: #a12b1f;
  --ok: #1d6a3f;
  --radius: 14px;
  --shadow: 0 2px 8px rgba(34, 34, 10, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Tajawal', 'Segoe UI', 'Arial', sans-serif;
  background: var(--paper);
  color: var(--ink);
  direction: rtl;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

.app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--cream);
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.08);
}

/* ---------------------------------- الترويسة --------------------------------- */

.header {
  position: relative;
  background: var(--rose);
  aspect-ratio: 1 / 1;
  max-height: 46vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
}

.header--slim {
  aspect-ratio: auto;
  min-height: 150px;
  padding: 22px 16px;
}

.header__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.header__text {
  position: relative;
  color: #fff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  padding: 12px 18px;
}

.header__text h1 {
  margin: 0;
  font-size: 30px;
  font-weight: 800;
  line-height: 1.5;
}

.header__text p {
  margin: 4px 0 0;
  font-size: 26px;
  font-weight: 700;
}

.header__img + .header__text {
  /* مع وجود صورة العنوان المصممة يُخفى النص لئلا يزدحم التصميم */
  display: none;
}

.page-badge {
  position: absolute;
  top: 14px;
  inset-inline-start: 14px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
  border: 2px solid rgba(255, 255, 255, 0.75);
  text-decoration: none;
}

/* ---------------------------------- المحتوى ---------------------------------- */

.content {
  flex: 1;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.btn {
  display: block;
  width: 100%;
  border: 0;
  border-radius: var(--radius);
  padding: 15px 16px;
  font-family: inherit;
  font-size: 17px;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  text-decoration: none;
}

.btn--dark {
  background: var(--ink);
  color: #fff;
}

.btn--teal {
  background: var(--teal);
  color: #fff;
}

.btn--ghost {
  background: transparent;
  color: var(--ink);
  border: 1.5px solid var(--line);
}

.btn--sm {
  padding: 9px 12px;
  font-size: 14px;
  width: auto;
  display: inline-block;
}

.btn--danger {
  background: var(--danger);
  color: #fff;
}

.btn:active {
  transform: translateY(1px);
}

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

.family-chip {
  background: var(--teal);
  color: #fff;
  border: 0;
  border-radius: var(--radius);
  padding: 14px 8px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.family-chip:nth-child(even) {
  background: var(--teal-light);
}

.hint {
  text-align: center;
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1.9;
  margin: 0;
}

.ad {
  display: block;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.ad img {
  display: block;
  width: 100%;
}

/* ----------------------------------- النماذج ---------------------------------- */

.field {
  display: block;
}

.field > span {
  display: block;
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 6px;
}

input[type='text'],
input[type='password'],
input[type='url'],
textarea,
select {
  width: 100%;
  font-family: inherit;
  font-size: 16px;
  padding: 13px 14px;
  border-radius: var(--radius);
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--ink);
}

textarea {
  min-height: 110px;
  resize: vertical;
  line-height: 1.9;
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid var(--teal);
  outline-offset: 1px;
}

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

.choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice label {
  display: block;
  text-align: center;
  padding: 13px 8px;
  border-radius: var(--radius);
  background: #fff;
  border: 1.5px solid var(--line);
  font-weight: 700;
  cursor: pointer;
}

.choice input:checked + label {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
}

.choice label .muted {
  font-size: 13px;
  font-weight: 400;
}

.choice input:checked + label .muted {
  color: #fff;
  opacity: 0.85;
}

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

.card h2,
.card h3 {
  margin: 0 0 10px;
  font-size: 17px;
}

.muted {
  color: var(--ink-soft);
  opacity: 0.8;
  font-size: 14px;
}

.notice {
  border-radius: var(--radius);
  padding: 12px 14px;
  font-weight: 700;
  font-size: 15px;
  line-height: 1.8;
}

.notice--ok {
  background: #e2f1e6;
  color: var(--ok);
}

.notice--error {
  background: #fbe4e1;
  color: var(--danger);
}

.notice--info {
  background: #fff6cc;
  color: #6b5300;
}

.notice[hidden] {
  display: none;
}

/* ----------------------------------- الحوار ---------------------------------- */

.sheet {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 6, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
  padding: 12px;
}

.sheet[hidden] {
  display: none;
}

.sheet__box {
  background: var(--cream);
  border-radius: 20px;
  width: 100%;
  max-width: 496px;
  max-height: 86vh;
  overflow-y: auto;
  padding: 18px;
  box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.25);
}

.sheet__title {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 800;
  color: var(--teal);
}

.sheet__desc {
  margin: 8px 0 14px;
  line-height: 2;
  font-size: 16px;
}

.sheet h4 {
  margin: 14px 0 6px;
  font-size: 16px;
  color: var(--rose-dark);
}

.sheet ul {
  margin: 0;
  padding-inline-start: 20px;
  line-height: 2.1;
  font-size: 16px;
}

/* ---------------------------------- التذييل ---------------------------------- */

.footer {
  background: #fff;
  text-align: center;
  padding: 12px;
  font-size: 13px;
  color: var(--ink-soft);
}

.footer a {
  color: var(--teal);
  font-weight: 700;
  text-decoration: none;
}

.footer:empty {
  display: none;
}

/* ---------------------------------- الجداول ---------------------------------- */

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

.row--between {
  justify-content: space-between;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.item {
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fff;
}

.item + .item {
  margin-top: 0;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 700;
  background: #eee;
  color: var(--ink-soft);
}

.badge--wait {
  background: #fff1c2;
  color: #6b5300;
}

.badge--ok {
  background: #e2f1e6;
  color: var(--ok);
}

.tabs {
  display: flex;
  gap: 6px;
  background: #fff;
  border-radius: var(--radius);
  padding: 5px;
  box-shadow: var(--shadow);
  overflow-x: auto;
}

.tabs button {
  flex: 1 0 auto;
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-soft);
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
}

.tabs button[aria-selected='true'] {
  background: var(--ink);
  color: #fff;
}

.panel[hidden] {
  display: none;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.toggle input {
  width: 22px;
  height: 22px;
  accent-color: var(--teal);
}

.preview {
  width: 110px;
  height: 110px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1.5px solid var(--line);
  background: #fff;
}
