/* ==========================================================================
   تصميم موقع الصيانة — أزرق حبر + أصفر تحذير (ألوان الورش وعُدّة الفنيين)
   ========================================================================== */
:root {
  --ink: #0e1b2e;
  --ink-2: #1a2e4a;
  --steel: #e8edf3;
  --paper: #ffffff;
  --line: #c9d3df;
  --line-2: #dde4ec;
  --muted: #526479;
  --signal: #ffc61a;
  --signal-2: #f0b400;
  --signal-soft: #fff3bf;
  --blue: #2563eb;
  --ok: #0b8a4d;
  --ok-soft: #dcf3e6;
  --bad: #cc2b1f;
  --bad-soft: #fde8e6;
  --wait: #6f5000;
  --wait-soft: #fff0c2;
  --font-ui: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, system-ui, sans-serif;
  --font-display: 'Changa', 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--steel);
  color: var(--ink);
  font: 400 16px/1.75 var(--font-ui);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

/* ---------- الهيدر ---------- */
.topbar { background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 40; }
.topbar-in {
  max-width: 1120px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.logo { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.logo-mark {
  width: 36px; height: 36px; border-radius: 10px; background: var(--signal); color: var(--ink);
  display: grid; place-items: center; flex: none;
}
.logo-text { font: 800 21px/1 var(--font-display); letter-spacing: 0; }

.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who-name { font-weight: 600; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-id {
  font: 600 13px/1 var(--font-ui); background: rgba(255,255,255,.12); padding: 5px 8px;
  border-radius: 6px; color: #d7e0ec; direction: ltr; flex: none;
}

.nav { border-top: 1px solid rgba(255,255,255,.1); background: var(--ink-2); }
.nav-in {
  max-width: 1120px; margin: 0 auto; padding: 0 8px; display: flex; align-items: stretch;
  overflow-x: auto; scrollbar-width: none;
}
.nav-in::-webkit-scrollbar { display: none; }
.nav a {
  color: #b8c6da; text-decoration: none; font-weight: 600; font-size: 15px; white-space: nowrap;
  padding: 11px 14px 9px; border-bottom: 3px solid transparent;
}
.nav a:hover { color: #fff; }
.nav a.on { color: #fff; border-bottom-color: var(--signal); }
.nav-sep { width: 1px; background: rgba(255,255,255,.18); margin: 10px 8px; flex: none; }

/* ---------- الصفحة ---------- */
.page { max-width: 1120px; margin: 0 auto; padding: 24px 16px 64px; }
.page-narrow { max-width: 760px; }
.page-head { margin-bottom: 20px; }
.page-title { font: 800 30px/1.3 var(--font-display); }
.page-sub { color: var(--muted); margin-top: 4px; max-width: 62ch; }

.panel {
  background: var(--paper); border: 1.5px solid var(--line-2); border-radius: 14px;
  padding: 20px; margin-bottom: 16px;
}
.panel-h { font: 700 19px/1.4 var(--font-display); margin-bottom: 14px; }

/* ---------- الأزرار ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 20px; border-radius: 10px;
  border: 1.5px solid var(--ink); background: var(--paper); color: var(--ink);
  font-weight: 600; font-size: 16px; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, transform .08s;
}
.btn:hover { background: #f2f5f9; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--signal); }
.btn.primary:hover { background: var(--signal-2); }
.btn.dark { background: var(--ink); color: #fff; }
.btn.dark:hover { background: var(--ink-2); }
.btn.sm { min-height: 38px; padding: 0 14px; font-size: 14px; }
.btn.lg { min-height: 52px; font-size: 17px; font-weight: 700; }
.btn.block { width: 100%; }
.btn.ghost-light { background: transparent; color: #fff; border-color: rgba(255,255,255,.4); }
.btn.ghost-light:hover { background: rgba(255,255,255,.12); }
.btn[disabled] { opacity: .65; cursor: not-allowed; }
.btn.busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.busy::after {
  content: ""; position: absolute; width: 20px; height: 20px; border-radius: 50%;
  border: 3px solid rgba(14,27,46,.25); border-top-color: var(--ink);
  animation: spin .7s linear infinite;
}
.btn.dark.busy::after { border-color: rgba(255,255,255,.3); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- الحقول ---------- */
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field label, .field .label { display: block; font-weight: 600; font-size: 15px; margin-bottom: 6px; }
.opt { color: var(--muted); font-weight: 400; }
.field input[type=text], .field input[type=tel], .field input[type=password],
.field input[type=search], .field input[type=number], .field select, .field textarea {
  width: 100%; min-height: 48px; padding: 10px 14px; background: #fff;
  border: 1.5px solid var(--line); border-radius: 10px; font-size: 16px; line-height: 1.6;
}
.field textarea { resize: vertical; min-height: 96px; }
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(37,99,235,.28);
}
.field input[dir=ltr] { text-align: right; }
.field input[dir=ltr]::placeholder { text-align: right; }
.field.err input, .field.err textarea, .field.err select { border-color: var(--bad); background: #fffafa; }
.field-hint { color: var(--muted); font-size: 14px; margin-top: 5px; }
.field-err { color: var(--bad); font-size: 14px; font-weight: 600; margin-top: 5px; }
.form-alert {
  background: var(--bad-soft); color: #8d1a11; border: 1.5px solid #f2b9b3; border-radius: 10px;
  padding: 10px 14px; margin-bottom: 16px; font-weight: 600; font-size: 15px;
}
.counter { text-align: left; color: var(--muted); font-size: 13px; margin-top: 4px; direction: ltr; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.check { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-weight: 400 !important; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--ink); flex: none; }

.pw { position: relative; }
.pw input { padding-inline-end: 76px !important; }
.pw-toggle {
  position: absolute; inset-block: 6px; inset-inline-end: 6px; padding: 0 12px; border: 0; border-radius: 8px;
  background: var(--steel); color: var(--ink); font-size: 14px; font-weight: 600; cursor: pointer;
}

/* ---------- الاختيار (Segmented) ---------- */
.seg { display: inline-flex; border: 1.5px solid var(--ink); border-radius: 10px; overflow: hidden; background: #fff; }
.seg button {
  border: 0; background: transparent; padding: 8px 18px; font-weight: 600; cursor: pointer; font-size: 15px;
  display: inline-flex; align-items: center; gap: 6px; min-height: 42px;
}
.seg button + button { border-inline-start: 1.5px solid var(--ink); }
.seg button.on { background: var(--ink); color: #fff; }
.seg button b { font-weight: 700; background: rgba(14,27,46,.1); border-radius: 999px; padding: 0 8px; font-size: 13px; line-height: 20px; }
.seg button.on b { background: var(--signal); color: var(--ink); }

/* ---------- صفحة الدخول ---------- */
.auth-body .page { max-width: none; padding: 0; }
.auth { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-hero {
  background: var(--ink); color: #fff; padding: 40px 48px; display: flex; flex-direction: column; gap: 22px;
  background-image: repeating-linear-gradient(-45deg, transparent 0 22px, rgba(255,198,26,.06) 22px 44px);
}
.hero-title { font: 800 clamp(34px, 5vw, 54px)/1.25 var(--font-display); margin-top: auto; }
.hero-sub { color: #bccbe0; font-size: 18px; max-width: 34ch; }
.hero-devices { list-style: none; margin: 8px 0 auto; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; max-width: 520px; }
.hero-devices li {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px 7px 12px; border-radius: 999px;
  border: 1.5px solid rgba(255,255,255,.25); font-weight: 600; font-size: 15px; background: rgba(255,255,255,.05);
}
.auth-main { display: grid; place-items: center; padding: 32px 20px; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card .tabs { display: flex; margin-bottom: 24px; }
.auth-card .tabs button { flex: 1; justify-content: center; min-height: 46px; }
.auth-h { font: 800 26px/1.3 var(--font-display); margin-bottom: 18px; }

/* ---------- نموذج الطلب ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }

.loc-row { display: flex; align-items: center; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.loc-status { font-size: 14px; color: var(--muted); }
.loc-status.ok { color: var(--ok); font-weight: 600; }
.loc-status.bad { color: var(--bad); font-weight: 600; }
.map { margin-top: 12px; border: 1.5px solid var(--line); border-radius: 12px; overflow: hidden; position: relative; background: var(--steel); }
.map iframe { display: block; width: 100%; height: 190px; border: 0; }
.map-link {
  position: absolute; inset-block-end: 8px; inset-inline-start: 8px; background: #fff; border: 1.5px solid var(--ink);
  border-radius: 8px; padding: 3px 10px; font-size: 13px; font-weight: 600; text-decoration: none;
}

.map-clear { inset-inline-start: auto; inset-inline-end: 8px; cursor: pointer; color: var(--bad); border-color: var(--bad); font-family: inherit; line-height: 1.6; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 10px; }
.tile {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center;
  padding: 12px 6px 10px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer;
  transition: border-color .12s, background .12s;
}
.tile:hover { border-color: var(--ink); }
.tile input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.tile:focus-within { outline: 3px solid var(--blue); outline-offset: 2px; }
.tile-ic { font-size: 30px; line-height: 1.3; }
.tile-name { font-weight: 600; font-size: 14px; line-height: 1.4; }
.tile.on { border-color: var(--ink); background: var(--signal-soft); box-shadow: inset 0 0 0 1.5px var(--ink); }
.tile.on::after {
  content: ""; position: absolute; inset-block-start: 6px; inset-inline-end: 6px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--ink) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center/12px no-repeat;
}
.field.err .tiles .tile { border-color: var(--bad); }

/* التذكرة (ملخص + التكلفة) */
.ticket { position: sticky; top: 132px; background: var(--paper); border: 1.5px solid var(--ink); border-radius: 14px; }
.ticket-top { background: var(--ink); color: #fff; padding: 18px; border-radius: 12px 12px 0 0; }
.t-device { display: flex; align-items: center; gap: 12px; font: 800 24px/1.2 var(--font-display); }
.t-icon { font-size: 34px; line-height: 1; }
.t-brand { color: #bccbe0; margin-top: 8px; font-size: 15px; overflow-wrap: anywhere; }
.perf { position: relative; border-top: 2px dashed var(--ink); }
.perf::before, .perf::after {
  content: ""; position: absolute; top: -12px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--steel); border: 1.5px solid var(--ink);
}
.perf::before { inset-inline-start: -12px; }
.perf::after { inset-inline-end: -12px; }
.ticket-bottom { padding: 18px; display: grid; gap: 16px; }
.cost-label { color: var(--muted); font-size: 14px; font-weight: 600; }
.cost { font: 800 38px/1.2 var(--font-display); margin-top: 2px; }
.cost small { font: 600 17px var(--font-ui); margin-inline-start: 6px; }
.cost.idle { font: 600 17px/1.5 var(--font-ui); color: var(--muted); }
.cost.unknown { font: 700 19px/1.5 var(--font-ui); color: var(--wait); }

/* نجاح */
.success { max-width: 520px; margin: 24px auto; text-align: center; padding: 32px 24px; }
.success-mark { width: 68px; height: 68px; border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items: center; margin: 0 auto 14px; }
.success-id { color: var(--muted); margin: 4px 0 18px; }
.success-id strong { color: var(--ink); font: 800 22px var(--font-display); direction: ltr; unicode-bidi: isolate; }
.success-list { margin: 0 0 22px; text-align: start; border-top: 1.5px dashed var(--line); }
.success-list > div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 2px; border-bottom: 1.5px dashed var(--line); }
.success-list dt { color: var(--muted); }
.success-list dd { margin: 0; font-weight: 700; text-align: end; }
.actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---------- كروت الطلبات ---------- */
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.search { flex: 1 1 260px; max-width: 420px; }
.search.grow { max-width: 520px; }
.search input {
  width: 100%; min-height: 46px; padding: 8px 14px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; font-size: 16px;
}
.search input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(37,99,235,.28); }
.count { color: var(--muted); font-weight: 600; }

.orders { display: grid; gap: 14px; }
.order {
  display: grid; grid-template-columns: 8px minmax(0, 1fr); background: #fff; border: 1.5px solid var(--line-2);
  border-radius: 14px; overflow: hidden;
}
.order .stripe { background: var(--signal); }
.order.is-done .stripe { background: var(--ok); }
.order-body { padding: 16px 18px; display: grid; gap: 12px; min-width: 0; }
.order-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.order-no { font: 700 14px/1 var(--font-ui); background: var(--ink); color: #fff; border-radius: 6px; padding: 5px 8px; direction: ltr; }
.order-device { font: 800 21px/1.3 var(--font-display); display: inline-flex; align-items: center; gap: 8px; }
.order-time { color: var(--muted); font-size: 14px; margin-inline-start: auto; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 12px; border-radius: 999px; font-weight: 700; font-size: 13px; }
.badge.wait { background: var(--wait-soft); color: var(--wait); }
.badge.ok { background: var(--ok-soft); color: #075f35; }
.badge.admin { background: var(--signal); color: var(--ink); }
.badge.main { background: var(--ink); color: #fff; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px 20px; margin: 0; }
.facts > div { min-width: 0; }
.facts > div.wide { grid-column: 1 / -1; }
.facts dt { color: var(--muted); font-size: 13px; font-weight: 600; }
.facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.facts dd.ltr { direction: ltr; text-align: right; }
.fault { background: var(--steel); border-radius: 10px; padding: 10px 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.order-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; border-top: 1.5px dashed var(--line-2); padding-top: 12px; }
.order-foot .spacer { flex: 1; }
.link-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 12px; border: 1.5px solid var(--line);
  border-radius: 10px; background: #fff; text-decoration: none; font-weight: 600; font-size: 14px;
}
.link-btn:hover { border-color: var(--ink); }

.status-seg button { min-width: 96px; justify-content: center; }
.status-seg button.ok.on { background: var(--ok); color: #fff; }
.status-seg button.bad.on { background: var(--bad); color: #fff; }

/* ---------- المستخدمون ---------- */
.users { display: grid; gap: 10px; }
.urow {
  display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; align-items: center; gap: 12px 14px;
  background: #fff; border: 1.5px solid var(--line-2); border-radius: 14px; padding: 12px 16px;
}
.avatar { width: 48px; height: 48px; border-radius: 50%; background: var(--ink); color: var(--signal); display: grid; place-items: center; font: 800 20px var(--font-display); }
.urow.is-admin .avatar { box-shadow: 0 0 0 3px var(--signal); }
.u-name { font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.u-meta { color: var(--muted); font-size: 14px; display: flex; gap: 14px; flex-wrap: wrap; margin-top: 2px; }
.u-meta .ltr { direction: ltr; unicode-bidi: isolate; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; text-decoration: none;
  border: 1.5px solid var(--ink); background: #25d366; color: #fff; flex: none;
}
.icon-btn:hover { background: #1fb858; }

/* ---------- الأسعار ---------- */
.prices { display: grid; gap: 10px; }
.prow {
  display: grid; grid-template-columns: minmax(0, 1fr) 170px auto; align-items: center; gap: 12px;
  background: #fff; border: 1.5px solid var(--line-2); border-radius: 14px; padding: 12px 16px;
}
.p-name { display: flex; align-items: center; gap: 12px; font: 700 18px var(--font-display); }
.p-name .ic { font-size: 28px; }
.p-input { position: relative; }
.p-input input {
  width: 100%; min-height: 46px; padding: 8px 14px 8px 58px; border: 1.5px solid var(--line); border-radius: 10px; font-size: 17px; font-weight: 600; direction: ltr; text-align: right; background: #fff;
}
.p-input input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(37,99,235,.28); }
.p-input span { position: absolute; inset-block: 0; left: 12px; display: grid; place-items: center; color: var(--muted); font-size: 14px; font-weight: 600; pointer-events: none; }

/* ---------- حالات فاضية وتنبيهات ---------- */
.empty { text-align: center; padding: 48px 16px; color: var(--muted); display: grid; gap: 14px; justify-items: center; }
.toasts { position: fixed; inset-inline: 0; bottom: 20px; display: grid; justify-items: center; gap: 8px; z-index: 100; pointer-events: none; padding: 0 16px; }
.toast {
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 10px; font-weight: 600; max-width: 460px;
  box-shadow: 0 6px 24px rgba(14,27,46,.3); animation: toast-in .2s ease-out;
}
.toast.bad { background: var(--bad); }
.toast.ok { background: var(--ok); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- موبايل ---------- */
@media (max-width: 899px) {
  .layout { grid-template-columns: 1fr; }
  .page-request { padding-bottom: 130px; }
  .ticket {
    position: fixed; inset-inline: 0; bottom: 0; top: auto; border-width: 2px 0 0; border-radius: 0; z-index: 30;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .ticket-top, .perf { display: none; }
  .ticket-bottom { grid-template-columns: 1fr auto; align-items: center; padding: 10px 16px; gap: 12px; }
  .cost { font-size: 28px; }
  .cost.unknown { font-size: 15px; }
  .cost.idle { font-size: 15px; }
  .toasts { bottom: 100px; }

  .auth { grid-template-columns: 1fr; min-height: 0; }
  .auth-hero { padding: 24px 20px 28px; gap: 14px; }
  .hero-title { margin-top: 8px; font-size: 34px; }
  .hero-sub { font-size: 16px; }
  .hero-devices { margin: 0; }
  .hero-devices li { padding: 5px 11px 5px 9px; font-size: 14px; }
}
@media (max-width: 640px) {
  .page { padding: 18px 12px 56px; }
  .page-title { font-size: 25px; }
  .panel { padding: 16px; }
  .row-2 { grid-template-columns: 1fr; gap: 0; }
  .who-name { display: none; }
  .order-body { padding: 14px; }
  .order-time { margin-inline-start: 0; width: 100%; }
  .status-seg { width: 100%; }
  .status-seg button { flex: 1; }
  .order-foot .spacer { display: none; }
  .urow { grid-template-columns: 44px minmax(0, 1fr) auto; padding: 12px; }
  .urow .avatar { width: 44px; height: 44px; }
  .urow .u-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
  .tiles { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .tile { padding: 10px 4px 8px; }
  .prow { grid-template-columns: minmax(0, 1fr) auto; }
  .prow .p-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .prow .p-name { grid-column: 1 / -1; }
  .toolbar .seg { width: 100%; }
  .toolbar .seg button { flex: 1; justify-content: center; padding-inline: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}


/* ==========================================================================
   إضافات: CRUD للأدمن (مودال / أزرار) + تحسينات الاستجابة لكل المقاسات
   ========================================================================== */
.head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; }
.head-row > div { min-width: 0; flex: 1 1 280px; }
.head-row > .btn { flex: none; }

.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger:hover { background: #a82217; }
.btn.danger.busy::after { border-color: rgba(255,255,255,.3); border-top-color: #fff; }
.link-btn { cursor: pointer; font-family: inherit; color: var(--ink); }
.link-btn.danger { color: var(--bad); border-color: #f0b7b2; }
.link-btn.danger:hover { background: var(--bad-soft); border-color: var(--bad); }

.u-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.icon-btn.plain { background: #fff; color: var(--ink); cursor: pointer; border-color: var(--line); }
.icon-btn.plain:hover { background: var(--steel); border-color: var(--ink); }
.icon-btn.plain.bad { color: var(--bad); }
.icon-btn.plain.bad:hover { background: var(--bad-soft); border-color: var(--bad); }
.p-actions { display: flex; align-items: center; gap: 8px; }
.p-name .u-meta { margin: 0 4px; font: 500 13px var(--font-ui); }

.field select { appearance: none; -webkit-appearance: none; padding-inline-end: 40px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230e1b2e' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat left 12px center / 18px; }

/* المودال */
body.modal-open { overflow: hidden; }
.modal-back {
  position: fixed; inset: 0; z-index: 80; background: rgba(14,27,46,.6); display: grid; place-items: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); animation: fade-in .15s ease-out;
}
.modal {
  width: 100%; max-width: 520px; max-height: 100%; overflow: auto; background: var(--paper); border-radius: 16px;
  border: 1.5px solid var(--ink); box-shadow: 0 20px 60px rgba(14,27,46,.4); overscroll-behavior: contain;
}
.modal-head {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; background: var(--ink); color: #fff; border-radius: 14px 14px 0 0;
}
.modal-head h2 { font: 700 19px/1.4 var(--font-display); min-width: 0; overflow-wrap: anywhere; }
.modal-x { flex: none; width: 38px; height: 38px; border-radius: 10px; border: 1.5px solid rgba(255,255,255,.35); background: transparent; color: #fff; display: grid; place-items: center; cursor: pointer; }
.modal-x:hover { background: rgba(255,255,255,.14); }
.modal-form { padding: 18px; }
.modal-msg { margin-bottom: 18px; line-height: 1.8; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.modal-actions .btn { flex: 1 1 130px; }
@keyframes fade-in { from { opacity: 0; } }

/* ---------- شاشات كبيرة ---------- */
@media (min-width: 1400px) {
  .topbar-in, .nav-in, .page { max-width: 1240px; }
  .page-narrow { max-width: 820px; }
}
@media (min-width: 1800px) { body { font-size: 17px; } }

/* ---------- تابلت / شاشات متوسطة ---------- */
@media (min-width: 641px) and (max-width: 899px) {
  .page { padding-inline: 20px; }
  .auth-hero { padding: 32px 36px; }
}

/* ---------- موبايل ---------- */
@media (max-width: 640px) {
  .head-row > .btn { width: 100%; }
  .modal-back { align-items: end; padding: 0; }
  .modal { max-width: none; border-radius: 18px 18px 0 0; border-width: 1.5px 0 0; max-height: 92dvh; padding-bottom: env(safe-area-inset-bottom); }
  .modal-head { border-radius: 16px 16px 0 0; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { flex: none; width: 100%; }
  .order-foot { gap: 8px; }
  .order-foot .link-btn { flex: 1 1 calc(50% - 8px); justify-content: center; }
  .u-actions .role-btn { flex: 1 1 100%; }
  .search, .search.grow { max-width: none; flex-basis: 100%; }
  .count { width: 100%; }
}

/* ---------- موبايل صغير (320px وأقل) ---------- */
@media (max-width: 400px) {
  .topbar-in { padding: 8px 12px; gap: 8px; }
  .logo-text { font-size: 18px; }
  .logo-mark { width: 32px; height: 32px; }
  .who { gap: 6px; }
  .who-id { display: none; }
  .nav a { padding: 10px 11px 8px; font-size: 14px; }
  .page-title { font-size: 22px; }
  .panel { padding: 14px; }
  .btn { padding: 0 14px; }
  .facts { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .success { padding: 24px 14px; }
  .modal-form { padding: 14px; }
  .auth-main { padding: 24px 14px; }
  .hero-title { font-size: 30px; }
}

/* الشاشات العريضة القصيرة (موبايل بالعرض): التذكرة مش لازم تفضل لاصقة */
@media (max-height: 480px) and (orientation: landscape) {
  .ticket { position: static; }
  .page-request { padding-bottom: 56px; }
  .modal { max-height: 100%; }
}
@supports (padding: max(0px)) {
  .topbar-in, .nav-in { padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right)); }
}
