:root{
  --bg:#f6f2ea;
  --bg2:#eee7da;
  --card:#fffdf9;
  --ink:#122f28;
  --muted:#77736d;
  --line:#e6ded0;
  --green:#123d33;
  --green2:#1d5849;
  --gold:#b39258;
  --gold-soft:#e8d7b5;
  --ok:#28775b;
  --bad:#a9473d;
  --shadow:0 14px 40px rgba(30,45,38,.08);
}

*{
  box-sizing:border-box;
}

html{
  scroll-behavior:smooth;
}

body{
  margin:0;
  background:
    radial-gradient(circle at top right,rgba(179,146,88,.10),transparent 30%),
    linear-gradient(180deg,#faf7f1 0%,var(--bg) 100%);
  color:var(--ink);
  font-family:Arial,"Noto Sans Arabic",sans-serif;
  min-height:100vh;
}

button,
input,
select{
  font:inherit;
}

.wrap{
  width:min(1180px,100%);
  margin:auto;
  padding:24px;
}

/* ===== Header ===== */

.top{
  position:relative;
  overflow:hidden;
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:22px;
  padding:28px;
  color:#fff;
  background:
    radial-gradient(circle at 15% 0%,rgba(179,146,88,.26),transparent 32%),
    linear-gradient(135deg,#0d2c25,#16483b 65%,#1c5546);
  border:1px solid rgba(255,255,255,.08);
  border-radius:28px;
  box-shadow:0 20px 50px rgba(18,61,51,.18);
}

.top::after{
  content:"WIFAD";
  position:absolute;
  left:22px;
  bottom:-14px;
  font-size:74px;
  font-weight:800;
  letter-spacing:10px;
  color:rgba(255,255,255,.035);
  pointer-events:none;
}

.top h1{
  position:relative;
  margin:0 0 8px;
  font-size:clamp(27px,4vw,42px);
  line-height:1.25;
  letter-spacing:-.6px;
}

.top h1::before{
  content:"WIFAD";
  display:block;
  margin-bottom:8px;
  color:var(--gold-soft);
  font-size:12px;
  font-weight:700;
  letter-spacing:5px;
  direction:ltr;
}

.muted{
  color:var(--muted);
}

.top .muted{
  position:relative;
  color:#d9d2c8;
  line-height:1.8;
}

.top > div:last-child{
  position:relative;
  display:flex;
  flex-wrap:wrap;
  gap:9px;
}

/* ===== Buttons ===== */

button,
.btn{
  appearance:none;
  border:0;
  border-radius:14px;
  padding:12px 17px;
  background:var(--green);
  color:#fff;
  cursor:pointer;
  text-decoration:none;
  display:inline-flex;
  justify-content:center;
  align-items:center;
  gap:7px;
  transition:.2s ease;
  box-shadow:0 7px 18px rgba(18,61,51,.12);
}

button:hover,
.btn:hover{
  transform:translateY(-1px);
  background:var(--green2);
}

.apple-wallet-badge{
  display:inline-block;
  width:220px;
  max-width:80%;
  line-height:0;
  direction:ltr;
  text-decoration:none;
  border-radius:14px;
  transition:transform .2s ease,filter .2s ease;
}

.apple-wallet-badge svg{
  display:block;
  width:100%;
  height:auto;
}

.apple-wallet-badge:hover{
  transform:translateY(-1px);
  filter:brightness(1.08);
}

.apple-wallet-badge:focus-visible{
  outline:3px solid var(--gold);
  outline-offset:3px;
}

.top button{
  background:rgba(255,255,255,.11);
  border:1px solid rgba(255,255,255,.16);
  box-shadow:none;
  backdrop-filter:blur(8px);
}

.top button:hover{
  background:rgba(255,255,255,.18);
}

.btn2{
  background:#eee7da;
  color:var(--green);
  box-shadow:none;
}

.danger{
  background:#8f3b35;
}

.ok{
  background:var(--ok);
}

/* ===== Stats ===== */

.grid{
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:14px;
  margin:18px 0;
}

.card{
  position:relative;
  background:rgba(255,253,249,.94);
  border:1px solid var(--line);
  border-radius:22px;
  padding:20px;
  box-shadow:var(--shadow);
}

.grid .card{
  min-height:125px;
  overflow:hidden;
}

.grid .card::before{
  content:"";
  position:absolute;
  top:0;
  right:0;
  width:4px;
  height:100%;
  background:linear-gradient(var(--gold),#d7c293);
  border-radius:0 22px 22px 0;
}

.grid .card .muted{
  font-size:14px;
}

.num{
  margin-top:8px;
  font-size:36px;
  line-height:1;
  font-weight:800;
  color:var(--green);
}

/* ===== Forms ===== */

.card h2{
  margin:0 0 18px;
  font-size:22px;
}

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

.field{
  flex:1 1 180px;
}

.field label{
  display:block;
  margin:0 0 7px;
  color:var(--muted);
  font-size:13px;
  font-weight:700;
}

input,
select{
  width:100%;
  border:1px solid var(--line);
  border-radius:14px;
  background:#fff;
  padding:13px 14px;
  color:var(--ink);
  outline:none;
  transition:.2s ease;
}

input:focus,
select:focus{
  border-color:var(--gold);
  box-shadow:0 0 0 4px rgba(179,146,88,.12);
}

/* ===== Tables ===== */

table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
}

th,
td{
  padding:13px 10px;
  border-bottom:1px solid var(--line);
  text-align:right;
  vertical-align:middle;
}

th{
  color:#746d62;
  font-size:12px;
  font-weight:700;
  background:#faf7f1;
}

tbody tr{
  transition:.15s ease;
}

tbody tr:hover{
  background:#fbf8f2;
}

.badge{
  display:inline-flex;
  align-items:center;
  padding:6px 10px;
  border-radius:999px;
  background:#eee7da;
  color:var(--green);
  font-size:12px;
  font-weight:700;
}

.actions{
  display:flex;
  gap:7px;
  flex-wrap:wrap;
}

/* ===== Toast ===== */

.notice{
  position:fixed;
  left:20px;
  bottom:20px;
  display:none;
  max-width:360px;
  z-index:99;
  padding:14px 18px;
  color:#fff;
  background:var(--green);
  border:1px solid rgba(255,255,255,.15);
  border-radius:16px;
  box-shadow:0 18px 50px rgba(18,61,51,.25);
}

/* ===== Invitation pages ===== */

.hero{
  min-height:100vh;
  display:grid;
  place-items:center;
  padding:20px;
}

.invite{
  width:min(480px,100%);
  background:rgba(255,253,249,.96);
  border:1px solid var(--line);
  border-radius:30px;
  padding:34px;
  text-align:center;
  box-shadow:0 25px 70px rgba(28,49,41,.12);
}

.invite .orn{
  font-size:36px;
  color:var(--gold);
}

.qr{
  width:220px;
  max-width:100%;
  border-radius:18px;
  border:1px solid var(--line);
  padding:9px;
  background:#fff;
}

.split{
  display:grid;
  grid-template-columns:1.1fr .9fr;
  gap:16px;
}

/* ===== Mobile ===== */

@media(max-width:760px){

  .wrap{
    padding:14px;
  }

  .top{
    padding:23px 20px;
    border-radius:24px;
    align-items:flex-start;
    flex-direction:column;
  }

  .top::after{
    font-size:48px;
    left:12px;
  }

  .top > div:last-child{
    width:100%;
  }

  .top button{
    flex:1;
    min-width:130px;
  }

  .grid{
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:10px;
    margin:14px 0;
  }

  .grid .card{
    min-height:112px;
    padding:17px;
  }

  .num{
    font-size:32px;
  }

  .card{
    padding:17px;
    border-radius:19px;
    overflow:auto;
  }

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

  table{
    min-width:760px;
  }

  th,
  td{
    white-space:nowrap;
  }

  .actions{
    flex-wrap:nowrap;
  }

  button,
  .btn{
    min-height:44px;
  }

  .invite{
    padding:25px 18px;
    border-radius:25px;
  }

  .notice{
    left:12px;
    right:12px;
    bottom:12px;
    max-width:none;
  }
}

@media(max-width:390px){

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

  .top h1{
    font-size:27px;
  }

  .num{
    font-size:29px;
  }
}
  /* ===== WIFAD Customer Setup Page ===== */

body:has(#quota) .wrap{
  max-width:900px;
  padding:18px 14px 50px;
}

body:has(#quota) .top{
  position:relative;
  overflow:hidden;
  padding:30px 22px;
  margin-bottom:18px;
  border-radius:28px;
  background:
    radial-gradient(circle at 15% 0%,rgba(179,146,88,.28),transparent 34%),
    linear-gradient(135deg,#0d2c25,#16483b 65%,#1c5546);
  color:#fff;
  box-shadow:var(--shadow);
}

body:has(#quota) .top::after{
  content:"WIFAD";
  position:absolute;
  left:18px;
  bottom:-12px;
  font-size:58px;
  font-weight:800;
  letter-spacing:8px;
  color:rgba(255,255,255,.045);
  pointer-events:none;
}

body:has(#quota) .top h1{
  margin:0 0 8px;
  font-size:30px;
  color:#fff;
}

body:has(#quota) .top .muted{
  color:rgba(255,255,255,.78);
  line-height:1.8;
  max-width:600px;
}

body:has(#quota) #quota{
  position:relative;
  z-index:2;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  margin-top:14px;
  padding:9px 15px;
  border:1px solid rgba(232,215,181,.45);
  border-radius:999px;
  background:rgba(255,255,255,.10);
  color:#f2dfb8;
  font-weight:700;
}

body:has(#quota) .card{
  margin-bottom:16px;
  padding:22px 18px;
  border:1px solid var(--line);
  border-radius:24px;
  background:rgba(255,253,249,.96);
  box-shadow:0 10px 30px rgba(30,45,38,.06);
}

body:has(#quota) .card h2{
  margin:0 0 18px;
  color:var(--green);
  font-size:21px;
}

body:has(#quota) label{
  display:block;
  margin-bottom:7px;
  color:var(--ink);
  font-weight:700;
}

body:has(#quota) input,
body:has(#quota) select,
body:has(#quota) textarea{
  width:100%;
  min-height:50px;
  padding:12px 14px;
  border:1px solid var(--line);
  border-radius:14px;
  background:#fff;
  color:var(--ink);
  font-size:16px;
  outline:none;
  transition:.2s ease;
}

body:has(#quota) input:focus,
body:has(#quota) select:focus,
body:has(#quota) textarea:focus{
  border-color:var(--gold);
  box-shadow:0 0 0 3px rgba(179,146,88,.12);
}

body:has(#quota) .field{
  margin-bottom:15px;
}

body:has(#quota) button,
body:has(#quota) .btn{
  border-radius:14px;
  font-weight:700;
}

body:has(#quota) .btn{
  background:linear-gradient(135deg,var(--green),var(--green2));
  color:#fff;
  border:none;
  box-shadow:0 8px 18px rgba(18,61,51,.15);
}

body:has(#quota) .btn2{
  border:1px solid var(--green);
  background:#fff;
  color:var(--green);
}

body:has(#quota) table{
  border-collapse:separate;
  border-spacing:0;
  overflow:hidden;
  border:1px solid var(--line);
  border-radius:16px;
  background:#fff;
}

body:has(#quota) th{
  background:#f3ede4;
  color:var(--green);
}

body:has(#quota) th,
body:has(#quota) td{
  padding:12px 10px;
  border-bottom:1px solid var(--line);
}

@media(max-width:600px){
  body:has(#quota) .wrap{
    padding:12px 12px 40px;
  }

  body:has(#quota) .top{
    padding:25px 18px;
    border-radius:24px;
  }

  body:has(#quota) .top h1{
    font-size:27px;
  }

  body:has(#quota) .card{
    padding:19px 15px;
    border-radius:21px;
  }

  body:has(#quota) .row{
    grid-template-columns:1fr;
  }
}
/* ===== WIFAD Mobile Order Cards ===== */
@media (max-width: 600px) {
body:not(:has(#quota)) .order-row td:first-child {
  display: none !important;
}

  body:not(:has(#quota)) table {
    min-width: 0;
  }

  body:not(:has(#quota)) table thead {
    display: none;
  }

  body:not(:has(#quota)) table tbody,
  body:not(:has(#quota)) .order-row {
    display: block;
    width: 100%;
  }

  body:not(:has(#quota)) .order-row {
    margin-bottom: 16px;
    padding: 16px;
    background: #fffdf9;
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: 0 8px 24px rgba(30,45,38,.06);
  }

  body:not(:has(#quota)) .order-row td:not(.actions) {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    width: 100%;
    padding: 10px 2px;
    border-bottom: 1px solid var(--line);
    white-space: normal;
    text-align: left;
  }

  body:not(:has(#quota)) .order-row td:not(.actions)::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
  }
#event_time_box[hidden] {
  display: none !important;
}
  body:not(:has(#quota)) .order-row .actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
    width: 100%;
    min-width: 0;
    padding: 14px 0 0;
    border: 0;
  }

  body:not(:has(#quota)) .order-row .actions .btn,
  body:not(:has(#quota)) .order-row .actions .btn2,
  body:not(:has(#quota)) .order-row .actions .danger {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 48px;
    margin: 0;
    padding: 10px 6px;
    border-radius: 14px;
    white-space: normal;
    text-align: center;
        text-decoration: none;
  }
}

/* ===== WIFAD Invitation ===== */

.invite-kicker {
  text-align: center;
  color: var(--gold);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .5px;
  margin-bottom: 10px;
}

.invite-title {
  text-align: center;
  color: var(--green);
  font-size: clamp(30px, 8vw, 44px);
  line-height: 1.25;
  margin: 8px 0 22px;
}

.invitation-design {
  width: 100%;
  margin: 0 auto 24px;
  overflow: hidden;
  border-radius: 24px;
  background: #f4efe6;
  box-shadow: 0 14px 35px rgba(18,61,51,.12);
}

.invitation-design img {
  display: block;
  width: 100%;
  height: auto;
  margin: 0;
}

.invite-details {
  text-align: center;
  padding: 18px 12px;
  margin: 0 0 18px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.invite-host {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 18px;
  font-weight: 700;
}

.invite-date {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
}

.guest-welcome {
  text-align: center;
  padding: 24px 16px;
  margin-top: 18px;
  border-radius: 22px;
  background: linear-gradient(180deg, #faf6ee 0%, #fffdf9 100%);
  border: 1px solid var(--line);
}

.guest-label {
  color: var(--gold);
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 7px;
}

.guest-welcome h2 {
  color: var(--green);
  font-size: 27px;
  margin: 4px 0 10px;
}

.guest-welcome p {
  margin: 0;
}
/* WIFAD setup checkbox fix */
body:has(#quota) input[type="checkbox"] {
  width: 22px;
  height: 22px;
  min-height: 22px;
  padding: 0;
  margin: 0;
  flex: 0 0 22px;
  accent-color: var(--green);
  box-shadow: none;
}

body:has(#quota) label:has(input[type="checkbox"]) {
  display: flex;
  align-items: center;
  gap: 10px;
  direction: rtl;
  width: fit-content;
  font-weight: 700;
}
/* WIFAD setup date & time width fix */
body:has(#quota) input[type="date"],
body:has(#quota) input[type="time"] {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  display: block;
}
/* Fix Safari date/time grid overflow */
body:has(#quota) .row,
body:has(#quota) .field,
body:has(#quota) #event_time_box {
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

body:has(#quota) .field > input:not([type="checkbox"]),
body:has(#quota) #event_time_box > input {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
/* Fix iPhone Safari date/time field overflow */
body:has(#quota) .row > .field {
  min-width: 0;
  width: 100%;
}

body:has(#quota) input[type="date"],
body:has(#quota) input[type="time"] {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
}
@media (max-width: 700px) {
  body:has(#quota) table thead {
    display: none;
  }

  body:has(#quota) table,
  body:has(#quota) table tbody,
  body:has(#quota) .guest-row,
  body:has(#quota) .guest-row td {
    display: block;
    width: 100%;
  }

  body:has(#quota) .guest-row {
    box-sizing: border-box;
    margin-bottom: 14px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--card);
  }

  body:has(#quota) .guest-row td {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border: 0;
    text-align: right;
  }

  body:has(#quota) .guest-row td::before {
    content: attr(data-label);
    font-weight: 700;
    color: var(--muted);
  }

  body:has(#quota) .guest-phone {
    direction: ltr;
    unicode-bidi: isolate;
    display: inline-block;
    text-align: left;
}
}
@media (max-width: 700px) {
  body:has(#quota) table {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    table-layout: fixed;
  }

  body:has(#quota) table tbody,
  body:has(#quota) .guest-row {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  body:has(#quota) .guest-row td {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }
}
/* ===== WIFAD Order Page ===== */

body:has(.order-hero) .order-hero {
  position: relative;
  overflow: hidden;
  padding: 28px 24px;
  border-radius: 28px;
  background:
    radial-gradient(circle at 10% 10%, rgba(179,146,88,.18), transparent 32%),
    linear-gradient(135deg, #123d33, #0d3028);
  color: #fff;
  box-shadow: 0 18px 45px rgba(18,61,51,.16);
}

body:has(.order-hero) .order-hero::after {
  content: "WIFAD";
  position: absolute;
  left: 18px;
  bottom: -24px;
  font-size: 72px;
  font-weight: 800;
  letter-spacing: 8px;
  color: rgba(255,255,255,.045);
  pointer-events: none;
}

body:has(.order-hero) .order-brand {
  position: relative;
  z-index: 1;
  margin-bottom: 22px;
  color: #e8d7b5;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 7px;
}

body:has(.order-hero) .order-hero-content {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

body:has(.order-hero) .order-hero h1 {
  margin: 0 0 8px;
  color: #fff;
  font-size: clamp(28px, 5vw, 42px);
}

body:has(.order-hero) .order-hero p {
  margin: 0;
  color: rgba(255,255,255,.72);
  font-size: 15px;
}

body:has(.order-hero) .order-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

body:has(.order-hero) .order-hero-actions .btn {
  margin: 0;
  white-space: nowrap;
}

@media (max-width: 720px) {
  body:has(.order-hero) .order-hero {
    padding: 24px 20px;
    border-radius: 24px;
  }

  body:has(.order-hero) .order-hero-content {
    display: block;
  }

  body:has(.order-hero) .order-hero-actions {
    margin-top: 22px;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  body:has(.order-hero) .order-hero-actions .btn {
    width: 100%;
    text-align: center;
  }

  body:has(.order-hero) .order-hero-actions #csv {
    grid-column: 1 / -1;
  }
}
@media (max-width: 720px) {

  .order-guest-row {
    display: block;
    width: 100%;
    margin-bottom: 16px;
    padding: 14px 16px;
    box-sizing: border-box;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--card);
  }

  .order-guest-row td {
    display: flex;
    width: 100%;
    box-sizing: border-box;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border: 0;
    text-align: left;
  }

  .order-guest-row td::before {
    font-weight: 700;
    color: var(--muted);
    text-align: right;
  }

  .order-guest-row td:nth-child(1)::before {
    content: "#";
  }

  .order-guest-row td:nth-child(2)::before {
    content: "الاسم";
  }

  .order-guest-row td:nth-child(3)::before {
    content: "الجوال";
  }

  .order-guest-row td:nth-child(4)::before {
    content: "المرافقون";
  }

  .order-guest-row td:nth-child(5)::before {
    content: "الحضور";
  }

  .order-guest-row td:nth-child(6)::before {
    content: "الدخول";
  }

  .order-guest-row td:nth-child(7)::before {
    content: none;
  }

  .order-guest-row td:nth-child(3) {
    direction: rtl;
  }

.order-guest-row .actions {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.order-guest-row .actions > * {
  width: 100%;
  min-height: 48px;
  margin: 0;
  padding: 10px 6px;
}

.order-guest-row .actions > :nth-child(1),
.order-guest-row .actions > :nth-child(2) {
  grid-column: span 3;
}

.order-guest-row .actions > :nth-child(3),
.order-guest-row .actions > :nth-child(4),
.order-guest-row .actions > :nth-child(5) {
  grid-column: span 2;
}

  .order-guest-row .actions::before {
    width: 100%;
    grid-column: 1 / -1;
    content: "الإجراءات";
    direction: rtl;
  }
}
@media (max-width: 720px) {
  body:has(#summary) .order-guest-row td:nth-child(1) {
    display: none;
  }
}

@media (max-width: 720px) {
 #orders td.actions {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
    width: 100% !important;
  }
#orders td.actions > * {
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    margin: 0 !important;
    white-space: normal !important;
    text-align: center !important;
  }
}
