/* طبقة المظهر: «خط الرحلة» — مستوحاة من زخرفة المعين على حافلات KPTC */
:root {
  --lattice: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56'%3E%3Cpath d='M28 3L53 28L28 53L3 28Z' fill='none' stroke='white' stroke-width='2'/%3E%3C/svg%3E");
  --lattice-dark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56'%3E%3Cpath d='M28 3L53 28L28 53L3 28Z' fill='none' stroke='%232e2c78' stroke-width='2'/%3E%3C/svg%3E");
  --grad: linear-gradient(135deg, #2e2c78 0%, #1f1d5c 60%, #14133a 100%);
  --ease: cubic-bezier(.2, .8, .2, 1);
}
html, body { overflow-x: clip; }
body { background: var(--paper) var(--lattice-dark); background-size: 56px 56px; background-attachment: fixed; }
body::before { content: ""; position: fixed; inset: 0; background: var(--paper); opacity: .93; z-index: -1; }

/* ---------- الرأس ---------- */
.top { background: var(--grad); position: relative; overflow: hidden; border-bottom: 0; }
.top::before { content: ""; position: absolute; inset: 0; background: var(--lattice); background-size: 56px 56px; opacity: .09; }
.top::after { content: ""; position: absolute; inset-inline: 0; bottom: 0; height: 5px; background: repeating-linear-gradient(90deg, var(--sign) 0 26px, transparent 26px 40px); }
.top .wrap { position: relative; z-index: 1; padding-block: 16px; }
.brand .mark { box-shadow: 0 3px 0 #c9971a; }
.brand b { letter-spacing: .2px; }

/* ---------- البطل (hero) ---------- */
.hero { position: relative; border-radius: 22px; overflow: hidden; color: #fff; margin: 18px 0 18px; min-height: 210px; display: flex; align-items: flex-end; box-shadow: var(--shadow); isolation: isolate; }
.hero::before { content: ""; position: absolute; inset: 0; background: var(--hero-img, none) center 40% / cover; z-index: -2; transform: scale(1.04); animation: kenburns 22s ease-in-out infinite alternate; }
.hero::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(0deg, rgba(20, 19, 58, .92) 0%, rgba(31, 29, 92, .55) 55%, rgba(46, 44, 120, .25) 100%); }
.hero .in { padding: 22px 24px; width: 100%; }
.hero h1 { color: #fff; font-size: 30px; margin: 0 0 4px; text-shadow: 0 2px 10px rgba(0, 0, 0, .35); }
.hero p { margin: 0 0 12px; opacity: .93; max-width: 560px; }
.hero .pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .3); backdrop-filter: blur(6px); padding: 3px 14px; border-radius: 99px; font-size: 14px; font-weight: 700; }
.pill.gold { background: var(--sign); color: var(--ink); border-color: var(--sign); }
@keyframes kenburns { from { transform: scale(1.04) translateX(0); } to { transform: scale(1.12) translateX(-2%); } }
.hero.big { min-height: 340px; }
.hero.big h1 { font-size: 38px; }

/* ---------- خط الرحلة (التقدم) ---------- */
.steps, .bar { display: none; }
.route { position: relative; margin: 22px 6px 12px; padding-top: 34px; }
.route .line { position: absolute; top: 49px; inset-inline: 17px; height: 6px; border-radius: 6px; background: repeating-linear-gradient(90deg, var(--line-2) 0 10px, transparent 10px 18px); }
.route .fill { position: absolute; top: 49px; inset-inline-start: 17px; height: 6px; border-radius: 6px; background: var(--sign); width: calc((100% - 34px) * var(--p)); transition: width .6s var(--ease); box-shadow: 0 0 0 1px rgba(201, 151, 26, .4); }
.route ol { list-style: none; margin: 0; padding: 0; display: flex; justify-content: space-between; position: relative; }
.route li { width: 34px; display: flex; flex-direction: column; align-items: center; font-size: 13px; color: var(--muted); }
.route li i { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--card); border: 3px solid var(--line-2); font-style: normal; font-weight: 800; transition: all .35s var(--ease); z-index: 1; }
.route li span { margin-top: 8px; white-space: nowrap; font-weight: 600; }

.route li.done i { background: var(--ok); border-color: var(--ok); color: #fff; }
.route li.cur i { background: var(--indigo); border-color: var(--indigo); color: #fff; box-shadow: 0 0 0 6px rgba(61, 59, 149, .2); transform: scale(1.12); }
.route li.cur span { color: var(--ink); }
.route .bus { position: absolute; top: 0; inset-inline-start: calc(17px + (100% - 34px) * var(--p)); transform: translateX(50%); transition: inset-inline-start .6s var(--ease); width: 46px; filter: drop-shadow(0 3px 2px rgba(20, 19, 58, .25)); animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 0%, 100% { margin-top: 0; } 50% { margin-top: -2px; } }

/* ---------- بطاقات الخدمات بالصور ---------- */
.tiles { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.tile.photo { padding: 0; flex-direction: column; align-items: stretch; gap: 0; overflow: hidden; min-height: 0; position: relative; transition: transform .25s var(--ease), box-shadow .25s, border-color .2s; }
.tile.photo .ph { display: block; width: 100%; height: 132px; background: var(--img) center / cover; position: relative; transition: transform .6s var(--ease); }
.tile.photo:hover .ph, .tile.photo:focus-visible .ph { transform: scale(1.06); }
.tile.photo .phw { display: block; overflow: hidden; height: 132px; position: relative; }
.tile.photo .phw::after { content: ""; position: absolute; inset: 0; background: linear-gradient(0deg, rgba(20, 19, 58, .55), transparent 60%); }
.tile.photo .ic { position: absolute; inset-inline-start: 14px; top: 108px; width: 48px; height: 48px; border-radius: 14px; background: var(--sign); display: grid; place-items: center; font-size: 26px; box-shadow: 0 4px 0 #c9971a; z-index: 2; }
.tile.photo .tb { display: block; padding: 30px 16px 16px; text-align: right; }
.tile.photo { overflow: hidden; }
.tile.photo[aria-pressed=true] { border-color: var(--indigo); box-shadow: 0 0 0 4px rgba(61, 59, 149, .22), var(--shadow); }
.tile.photo[aria-pressed=true]::after { content: "✓"; position: absolute; top: 10px; inset-inline-end: 10px; width: 32px; height: 32px; border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items: center; font-weight: 900; }
.tile.photo:hover { transform: translateY(-4px); box-shadow: 0 14px 30px rgba(20, 19, 58, .18); }
.tile.photo.any .phw { background: var(--grad); } .tile.photo.any .ph { background-image: var(--lattice); background-size: 56px 56px; opacity: .2; }

/* ---------- الأزرار (ملمس ضغط) ---------- */
.btn-primary { background: linear-gradient(180deg, #3d3b95, #2e2c78); box-shadow: 0 4px 0 #1f1d5c; }
.btn-sign { box-shadow: 0 4px 0 #c9971a; }
.btn-primary:active, .btn-sign:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, .3); }
.btn-ghost { background: var(--card); }
.card { transition: box-shadow .2s; }
.chip { transition: transform .12s, background .15s, border-color .15s; } .chip:active { transform: scale(.96); }
.chip[aria-pressed=true] { box-shadow: 0 3px 0 #1f1d5c; }

/* ---------- بطاقة الاستلام: تذكرة ---------- */
.receipt { padding: 0; border: 2px solid var(--indigo); border-radius: 20px; background: #fff; animation: pop .5s var(--ease) both; }
.receipt::before { display: none; }
.receipt .rt { background: var(--grad); color: #fff; padding: 20px 24px 18px; text-align: center; position: relative; overflow: hidden; }
.receipt .rt::before { content: ""; position: absolute; inset: 0; background: var(--lattice); background-size: 56px 56px; opacity: .08; }
.receipt .rt b { font-size: 20px; position: relative; } .receipt .rt .lead { color: rgba(255, 255, 255, .8); margin: 0; position: relative; }
.receipt .ref { background: var(--sign); color: var(--ink); margin: 12px 0 0; position: relative; box-shadow: 0 4px 0 #c9971a; letter-spacing: 1.5px; }
.receipt .rb { padding: 18px 24px 8px; }
.receipt .tear { position: relative; border-top: 3px dashed var(--line-2); margin: 10px 0 0; }
.receipt .tear::before, .receipt .tear::after { content: ""; position: absolute; top: -17px; width: 30px; height: 30px; border-radius: 50%; background: var(--paper); border: 2px solid var(--indigo); }
.receipt .tear::before { inset-inline-start: -18px; } .receipt .tear::after { inset-inline-end: -18px; }
.receipt .rf { padding: 14px 24px 22px; }
.receipt .conf { margin: 0; }
.receipt .barcode { height: 34px; margin-top: 12px; opacity: .85; background: repeating-linear-gradient(90deg, var(--ink) 0 2px, transparent 2px 5px, var(--ink) 5px 6px, transparent 6px 10px, var(--ink) 10px 14px, transparent 14px 16px); border-radius: 3px; }
@keyframes pop { from { opacity: 0; transform: translateY(18px) scale(.97); } to { opacity: 1; transform: none; } }

/* حافلة تعبر الطريق عند نجاح الحفظ */
.drive { position: relative; height: 52px; overflow: hidden; margin: 6px 0 10px; border-bottom: 4px solid var(--ink); }
.drive::after { content: ""; position: absolute; inset-inline: 0; bottom: -2px; height: 4px; background: repeating-linear-gradient(90deg, var(--sign) 0 22px, transparent 22px 40px); }
.drive svg { position: absolute; bottom: 4px; width: 78px; inset-inline-start: 110%; animation: drive 2.4s var(--ease) .1s forwards; }
@keyframes drive { to { inset-inline-start: -30%; } }
.okmark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--ok); color: #fff; margin-inline-end: 8px; animation: pop .5s var(--ease) both; }

/* ---------- الجهاز اللوحي / الترحيب ---------- */
.welcome { padding: 0; }
.welcome .hero { margin-top: 18px; }
.welcome .cta { text-align: center; margin: 22px 0; }
.welcome .big { font-size: 24px; padding: 18px 46px; min-height: 76px; border-radius: 18px; animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 4px 0 #1f1d5c, 0 0 0 0 rgba(61, 59, 149, .4); } 50% { box-shadow: 0 4px 0 #1f1d5c, 0 0 0 14px rgba(61, 59, 149, 0); } }
.kbanner { background: var(--sign); color: var(--ink); font-weight: 800; text-align: center; padding: 10px 16px; position: sticky; top: 0; z-index: 30; box-shadow: 0 2px 10px rgba(0, 0, 0, .15); }
.paused { position: fixed; inset: 0; z-index: 90; background: var(--grad); color: #fff; display: grid; place-items: center; text-align: center; padding: 30px; }
.paused h1 { color: #fff; font-size: 34px; } .paused .ic { font-size: 70px; }

/* ---------- لوحة الموظفين ---------- */
.live { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .25); border-radius: 99px; padding: 2px 12px; color: #fff; cursor: pointer; font-family: inherit; }
.live i { width: 9px; height: 9px; border-radius: 50%; background: #55e39b; box-shadow: 0 0 0 0 rgba(85, 227, 155, .7); animation: ping 1.8s infinite; }
.live.off i { background: #ff6b60; animation: none; }
@keyframes ping { 70% { box-shadow: 0 0 0 9px rgba(85, 227, 155, 0); } 100% { box-shadow: 0 0 0 0 rgba(85, 227, 155, 0); } }
.nav { box-shadow: 0 2px 12px rgba(20, 19, 58, .06); }
.nav a { transition: background .15s; } .nav a:not(.on):hover { background: #eceafc; }
.kpi { position: relative; overflow: hidden; transition: transform .15s var(--ease), box-shadow .15s; padding-inline-start: 20px; }
.kpi::before { content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: 6px; background: var(--indigo-2); }
.kpi.warn::before { background: var(--bad); } .kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.kpi .ic { position: absolute; inset-inline-end: 10px; top: 8px; font-size: 24px; opacity: .85; }
.dept { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; padding: 1px 10px; border-radius: 99px; background: color-mix(in srgb, var(--dc, #2e2c78) 14%, white); color: var(--dc, #2e2c78); border: 1px solid color-mix(in srgb, var(--dc, #2e2c78) 35%, white); white-space: nowrap; }
.dept::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--dc, #2e2c78); }
.rq { transition: transform .15s var(--ease), box-shadow .15s, border-color .15s; border-inline-start: 5px solid var(--dc, var(--line)); }
.rq:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.rq.fresh { animation: flash 2.4s ease-out; }
@keyframes flash { 0% { background: #fff4d6; box-shadow: 0 0 0 4px rgba(255, 201, 60, .6); } 100% { background: var(--card); } }
.alertbar { background: var(--sign); color: var(--ink); border-radius: 14px; padding: 10px 16px; font-weight: 800; display: flex; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 12px; animation: pop .4s var(--ease); }
.devcard { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #aaa; margin-inline-end: 6px; } .dot.on { background: #1e7f55; box-shadow: 0 0 0 4px rgba(30, 127, 85, .2); }
.callbar { display: flex; gap: 10px; flex-wrap: wrap; margin: 8px 0 4px; }
.callbar .btn { flex: 1; min-width: 140px; }

/* ---------- ملصق الجناح ---------- */
.poster { background: #fff; border-radius: 24px; overflow: hidden; max-width: 560px; margin: 0 auto; border: 3px solid var(--indigo); text-align: center; box-shadow: var(--shadow); }
.poster .ph { background: var(--grad); color: #fff; padding: 26px 24px 22px; position: relative; overflow: hidden; }
.poster .ph::before { content: ""; position: absolute; inset: 0; background: var(--lattice); background-size: 56px 56px; opacity: .1; }
.poster .ph * { position: relative; } .poster h2 { color: #fff; font-size: 44px; margin: 0; line-height: 1.2; } .poster .sub { font-size: 20px; opacity: .92; }
.poster .qrw { padding: 24px; } .poster .qrw svg { width: 100%; max-width: 360px; height: auto; border: 8px solid var(--sign); border-radius: 18px; padding: 10px; background: #fff; }
.poster .steps3 { display: flex; justify-content: center; gap: 14px; padding: 0 16px 8px; flex-wrap: wrap; }
.poster .steps3 div { flex: 1; min-width: 120px; font-weight: 700; font-size: 16px; } .poster .steps3 b { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--sign); margin: 0 auto 4px; font-size: 22px; }
.poster .url { direction: ltr; font-family: ui-monospace, Consolas, monospace; background: var(--paper); padding: 8px; margin: 12px 20px 4px; border-radius: 10px; font-size: 15px; word-break: break-all; }
.poster .pf { padding: 8px 20px 22px; color: var(--muted); font-size: 14px; }

@media (max-width: 560px) { .hero h1 { font-size: 24px; } .hero.big h1 { font-size: 28px; } .route li span { font-size: 11px; } .poster h2 { font-size: 34px; } }
@media (prefers-reduced-motion: reduce) { .hero::before, .route .bus, .welcome .big, .drive svg { animation: none !important; } .drive svg { inset-inline-start: 40%; } }
@media print {
  body::before { display: none; } body { background: #fff; }
  .receipt .tear::before, .receipt .tear::after { background: #fff; }
  .poster { box-shadow: none; border-width: 4px; max-width: none; } .drive, .hero { display: none; }
  .poster .ph, .receipt .rt, .receipt .ref { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}

.top .btn-ghost { background: rgba(255, 255, 255, .1); color: #fff; border-color: rgba(255, 255, 255, .45); box-shadow: none; }
.rq > span { min-width: 0; } .rq .dept { white-space: normal; max-width: 100%; margin-top: 4px; }
.receipt .ref { white-space: nowrap; font-size: clamp(20px, 7.2vw, 32px); }
@media (max-width: 560px) { .actions .btn { padding-inline: 12px; font-size: 16px; flex: 1 1 42%; min-width: 0; } .receipt .rb, .receipt .rf, .receipt .rt { padding-inline: 16px; } }
