@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700;800&display=swap');

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  --ink:#182033; --navy:#111B2E; --surface:#F7F8FA; --card:#FFF; --line:#E1E5EA;
  --accent:#D64020; --accent-dark:#A92F18; --green:#2E9F73; --amber:#C98A1A; --muted:#596579; --late:#DC2626;
  direction: rtl;
  font-family: 'Tajawal', system-ui, sans-serif;
  background: var(--surface);
  color: var(--ink);
  min-height: 100vh;
}
button { font-family: inherit; border: none; cursor: pointer; }
input { font-family: inherit; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.tp { background: var(--navy); color: #fff; padding: 12px 16px; }
.tp-in { max-width: 1020px; margin: 0 auto; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.bd { font-size: 21px; font-weight: 700; letter-spacing: -.5px; }
.tabs { display: flex; gap: 5px; margin-inline-start: auto; flex-wrap: wrap; }
.tab { background: transparent; color: #9CA9C2; padding: 8px 13px; border-radius: 8px; font-size: 13.5px; }
.tab.on { background: var(--accent); color: #fff; font-weight: 600; }
.who { font-size: 13px; color: #9CA9C2; }
.who button { color: #fff; text-decoration: underline; background: none; font-size: 13px; padding: 0; margin-inline-start: 8px; }
.main { max-width: 1020px; margin: 0 auto; padding: 22px 16px 60px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.lbl { font-size: 14px; color: var(--muted); margin: 0 0 9px; display: block; }
.inp { width: 100%; padding: 14px 16px; font-size: 27px; font-weight: 600; border: 2px solid var(--line);
  border-radius: 10px; background: var(--surface); color: var(--ink); text-align: center; }
.btn { padding: 13px 22px; border-radius: 10px; font-size: 15px; font-weight: 600; color: #fff; background: var(--ink); }
.btn.accent { background: var(--accent); }
.btn.green { background: var(--green); }
.btn.amber { background: var(--amber); color: var(--ink); }
.btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn:disabled { opacity: .55; cursor: default; }
.h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; display: flex; align-items: center; gap: 9px; }
.pill { background: var(--line); color: var(--ink); border-radius: 20px; padding: 2px 10px; font-size: 12.5px; font-weight: 500; }
.empty { color: var(--muted); font-size: 14px; margin: 0; }
.note { font-size: 13px; color: var(--muted); line-height: 1.75; margin: 14px 0 0; }
.err { font-size: 13.5px; color: var(--accent-dark); background: rgba(214,64,32,.08); border-radius: 10px; padding: 10px 14px; margin: 0 0 14px; }
.row { background: var(--card); border: 1px solid var(--line); border-inline-start: 5px solid var(--amber);
  border-radius: 12px; padding: 13px 15px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row .n { font-size: 26px; font-weight: 700; line-height: 1; }
.row .m { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.acts { display: flex; gap: 8px; margin-inline-start: auto; }

/* ذيل الفاتورة القابل للطباعة */
.ticket { background: #fff; border: 1px dashed #9AA8A5; border-radius: 12px; padding: 20px; text-align: center; max-width: 300px; }
.ticket .venue { font-size: 13px; color: var(--muted); margin: 0; }
.ticket .num { font-size: 44px; font-weight: 700; line-height: 1; margin: 6px 0 12px; letter-spacing: -1px; }
.ticket .qr { line-height: 0; display: inline-block; }
.ticket .cta { font-size: 13.5px; line-height: 1.7; margin: 12px 0 0; color: var(--ink); }

/* الشاشة الأمامية */
.disp { background: var(--navy); border-radius: 18px; padding: 32px 24px; text-align: center; color: #fff; }
.disp .k { font-size: 15px; color: #EFA089; margin: 0; }
.disp .big { font-size: 74px; font-weight: 700; line-height: 1; letter-spacing: -2px; margin: 6px 0 18px; }
.qrw { background: #fff; padding: 14px; border-radius: 14px; display: inline-block; line-height: 0; }
.disp .how { font-size: 16px; margin: 18px 0 0; color: rgba(255,255,255,.75); }

/* شارة "مباشر" */
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--green);
  background: rgba(46,159,115,.12); border-radius: 20px; padding: 4px 12px 4px 10px; }
.live i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); display: inline-block; animation: dot 1.6s ease-in-out infinite; }
@keyframes dot { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* خطوات الاستخدام الثلاث */
.steps { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.steps span { font-size: 12px; color: var(--muted); background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px; padding: 6px 12px; display: flex; align-items: center; gap: 6px; }
.steps b { width: 16px; height: 16px; border-radius: 50%; background: var(--ink); color: #fff; font-size: 10px;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }

/* التحضير */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
.tile { background: var(--card); border: 2px solid var(--line); border-radius: 14px; padding: 16px 8px; text-align: center; }
.tile .n { font-size: 31px; font-weight: 700; line-height: 1; }
.tile .m { font-size: 12px; color: var(--muted); margin-top: 6px; }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; max-width: 290px; }
.pad button { padding: 17px 0; font-size: 23px; font-weight: 600; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; color: var(--ink); }

/* جوال العميل */
.phone { max-width: 400px; margin: 10px auto; background: var(--card); border: 1px solid var(--line);
  border-radius: 22px; padding: 24px; box-shadow: 0 10px 34px rgba(17,30,28,.1); }
.phone.rdy { background: #F3FBF8; border-color: rgba(46,159,115,.3); }
.circ { width: 184px; height: 184px; margin: 12px auto 14px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 86px; font-weight: 700; letter-spacing: -3px; border: 3px solid var(--line);
  color: var(--ink); line-height: 1; }
.phone.rdy .circ { border-color: var(--green); color: var(--green); animation: pls 1.6s ease-out 3; }
@keyframes pls { 0% { box-shadow: 0 0 0 0 rgba(46,159,115,.4); } 70% { box-shadow: 0 0 0 30px rgba(46,159,115,0); } 100% { box-shadow: 0 0 0 0 rgba(46,159,115,0); } }
.phone.late { background: #FEF2F2; border-color: rgba(220,38,38,.35); }
.phone.late .circ { border-color: var(--late); color: var(--late); animation: plsLate 1.6s ease-in-out infinite; }
@keyframes plsLate { 0% { box-shadow: 0 0 0 0 rgba(220,38,38,.45); } 70% { box-shadow: 0 0 0 22px rgba(220,38,38,0); } 100% { box-shadow: 0 0 0 0 rgba(220,38,38,0); } }
.check { width: 44px; height: 44px; border-radius: 50%; background: var(--green); color: #fff; font-size: 22px;
  display: flex; align-items: center; justify-content: center; margin: 0 auto 10px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 26px; }
.stat .v { font-size: 35px; font-weight: 700; line-height: 1; letter-spacing: -1px; }
.stat .l { font-size: 13.5px; color: var(--muted); margin-top: 8px; }

/* شاشة تسجيل الدخول */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 360px; background: var(--card); border: 1px solid var(--line);
  border-radius: 18px; padding: 30px 26px; box-shadow: 0 20px 50px rgba(24,32,51,.08); }
.login-card .brand { font-size: 24px; font-weight: 800; color: var(--ink); margin: 0 0 4px; }
.login-card .sub { font-size: 13.5px; color: var(--muted); margin: 0 0 22px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 6px; }
.field input { width: 100%; padding: 12px 14px; font-size: 15px; border: 2px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink); }

/* جداول وشارات لوحة الإدارة */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: start; font-weight: 600; color: var(--muted); font-size: 12.5px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.badge { display: inline-block; border-radius: 20px; padding: 3px 10px; font-size: 12px; font-weight: 600; }
.badge.ok { background: rgba(46,159,115,.12); color: var(--green); }
.badge.bad { background: rgba(214,64,32,.1); color: var(--accent-dark); }
.badge.muted { background: var(--line); color: var(--muted); }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px; margin-bottom: 20px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.lock-wrap { min-height: 60vh; display: flex; align-items: center; justify-content: center; padding: 30px; text-align: center; }

@media print {
  body * { visibility: hidden; }
  #ticketPrint, #ticketPrint * { visibility: visible; }
  #ticketPrint { position: absolute; inset-inline-start: 0; top: 0; border: none; }
}
