/* Al Mujtama visit permits - mobile first, RTL first (logical properties only) */
@font-face { font-family: "Plex Arabic"; font-weight: 400; font-display: swap;
  src: url(/static/fonts/ibm-plex-sans-arabic-arabic-400-normal.woff2) format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "Plex Arabic"; font-weight: 700; font-display: swap;
  src: url(/static/fonts/ibm-plex-sans-arabic-arabic-700-normal.woff2) format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "Plex Arabic"; font-weight: 400; font-display: swap;
  src: url(/static/fonts/ibm-plex-sans-arabic-latin-400-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Plex Arabic"; font-weight: 700; font-display: swap;
  src: url(/static/fonts/ibm-plex-sans-arabic-latin-700-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --green: #1f6b4f; --green-2: #2e9d6b; --green-soft: #e6f1ec;
  --red: #c0392b; --red-soft: #fbe9e7; --amber: #b7791f; --amber-soft: #fdf3e1;
  --bg: #f3f5f4; --surface: #ffffff; --text: #1b2a24; --muted: #63736c; --line: #dfe6e2;
  --radius: 14px; --shadow: 0 1px 2px rgba(16, 40, 30, .06), 0 4px 16px rgba(16, 40, 30, .06);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1613; --surface: #17211c; --text: #e6efea; --muted: #9db0a7; --line: #2a3832;
    --green-soft: #1b3229; --red-soft: #3a1d1a; --amber-soft: #3a2e17; --shadow: none; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.6 "Plex Arabic", "Segoe UI", Tahoma, system-ui, sans-serif; }
a { color: var(--green); }
@media (prefers-color-scheme: dark) { a { color: #6fd0a3; } }
img { max-inline-size: 100%; }
bdi, .ltr { unicode-bidi: isolate; }
.ltr { direction: ltr; }

/* header */
.top { background: var(--green); color: #fff; }
.top .in { display: flex; align-items: center; gap: 12px; max-inline-size: 1100px; margin-inline: auto; padding: 10px 16px; }
.top .logo { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; min-inline-size: 0; }
.top .logo img { inline-size: 34px; block-size: 34px; border-radius: 8px; background: #fff; }
.top .logo span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .sp { flex: 1; }
.top .lnk { color: #fff; text-decoration: none; font-size: 14px; padding: 6px 10px; border: 1px solid rgba(255,255,255,.35); border-radius: 999px; background: none; font-family: inherit; cursor: pointer; white-space: nowrap; }
.top form { margin: 0; }

main { max-inline-size: 1100px; margin-inline: auto; padding: 16px; }
main.narrow { max-inline-size: 520px; }
h1 { font-size: 1.35rem; margin: .4em 0 .6em; }
h2 { font-size: 1.1rem; margin: 1.2em 0 .5em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-block-end: 14px; }
.grid { display: grid; gap: 12px; }
@media (min-width: 700px) { .grid.two { grid-template-columns: 1fr 1fr; } .grid.three { grid-template-columns: repeat(3, 1fr); } }

/* forms */
label { display: block; font-weight: 700; font-size: .92rem; margin-block: 10px 4px; }
label .muted { font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=date], input[type=number], input[type=search], select, textarea {
  inline-size: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-block-size: 44px; }
textarea { min-block-size: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--green-2); outline-offset: 1px; }
input.code { font-size: 1.6rem; letter-spacing: .4em; text-align: center; direction: ltr; }
input[type=email], input[type=tel], .ltr-input { direction: ltr; text-align: start; }
[dir=rtl] input[type=email], [dir=rtl] input[type=tel], [dir=rtl] .ltr-input { text-align: end; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 6px 0; }
.check input { inline-size: 20px; block-size: 20px; accent-color: var(--green); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips .check { border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; margin: 0; background: var(--surface); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 700; border: 0; border-radius: 10px; padding: 10px 18px; min-block-size: 44px; cursor: pointer; text-decoration: none; background: var(--green); color: #fff; }
.btn.block { inline-size: 100%; }
.btn.ghost { background: transparent; color: var(--green); border: 1px solid var(--green); }
.btn.danger { background: var(--red); }
.btn.sm { min-block-size: 34px; padding: 5px 12px; font-size: .88rem; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row.end { justify-content: flex-end; }
.inline { display: inline; margin: 0; }

.flash { border-radius: 10px; padding: 10px 14px; margin-block-end: 14px; border: 1px solid; }
.flash.ok { background: var(--green-soft); border-color: var(--green-2); }
.flash.err { background: var(--red-soft); border-color: var(--red); }
.flash.warn { background: var(--amber-soft); border-color: var(--amber); }

.badge { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: .8rem; font-weight: 700; white-space: nowrap; }
.b-active, .b-approved, .b-valid, .b-sent { background: var(--green-soft); color: var(--green); }
.b-expired, .b-revoked, .b-rejected, .b-not_found, .b-failed { background: var(--red-soft); color: var(--red); }
.b-pending, .b-not_started, .b-wrong_region { background: var(--amber-soft); color: var(--amber); }
@media (prefers-color-scheme: dark) { .b-active, .b-approved, .b-valid, .b-sent { color: #6fd0a3; } .b-expired, .b-revoked, .b-rejected, .b-not_found, .b-failed { color: #ff8f80; } .b-pending, .b-not_started, .b-wrong_region { color: #f0b45a; } }

/* landing choices */
.choices { display: grid; gap: 12px; }
.choice { display: flex; gap: 14px; align-items: center; text-decoration: none; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.choice .ic { flex: none; inline-size: 46px; block-size: 46px; border-radius: 12px; background: var(--green-soft); display: grid; place-items: center; color: var(--green); }
.choice b { display: block; }
.choice small { color: var(--muted); }

/* lists */
.list { display: grid; gap: 10px; }
.item { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.item .head { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 8px 0 0; font-size: .92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* tables (admin) - scroll horizontally inside their own box on phones */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
table { border-collapse: collapse; inline-size: 100%; font-size: .9rem; }
th, td { padding: 8px 10px; border-block-end: 1px solid var(--line); text-align: start; vertical-align: top; }
th { background: var(--green-soft); white-space: nowrap; }
td.nowrap { white-space: nowrap; }

/* admin nav */
.adminnav { display: flex; gap: 6px; overflow-x: auto; padding-block-end: 4px; margin-block-end: 12px; scrollbar-width: thin; }
.adminnav a { flex: none; text-decoration: none; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: .9rem; }
.adminnav a.on { background: var(--green); color: #fff; border-color: var(--green); }
.region-card .emails { direction: ltr; text-align: start; font-size: .85rem; overflow-wrap: anywhere; }
[dir=rtl] .region-card textarea.emails { text-align: end; }
textarea.emails { min-block-size: 70px; }
details > summary { cursor: pointer; font-weight: 700; padding: 4px 0; }

/* ---------- the pass ---------- */
.pass { max-inline-size: 400px; margin: 4px auto 16px; background: var(--surface); border-radius: 22px; overflow: hidden; box-shadow: 0 8px 30px rgba(16, 40, 30, .16); border: 1px solid var(--line); }
.pass .ph { background: linear-gradient(135deg, #1f6b4f, #2a8562); color: #fff; padding: 14px 18px; display: flex; align-items: center; gap: 12px; }
.pass .ph img { inline-size: 40px; block-size: 40px; border-radius: 10px; background: #fff; }
.pass .ph .t { flex: 1; min-inline-size: 0; }
.pass .ph b { display: block; font-size: 1.05rem; }
.pass .ph small { opacity: .85; }
.pass .status { border-radius: 999px; padding: 4px 12px; font-weight: 700; font-size: .85rem; background: #fff; }
.pass .status.active { color: var(--green); } .pass .status.expired, .pass .status.revoked { color: var(--red); } .pass .status.not_started { color: var(--amber); }
.pass .who { display: flex; gap: 14px; align-items: center; padding: 16px 18px 6px; }
.pass .who .photo { flex: none; inline-size: 72px; block-size: 72px; border-radius: 16px; object-fit: cover; background: var(--green-soft); display: grid; place-items: center; color: var(--green); font-size: 1.8rem; font-weight: 700; }
.pass .who .n { font-size: 1.2rem; font-weight: 700; line-height: 1.35; overflow-wrap: anywhere; }
.pass .who .c { color: var(--muted); overflow-wrap: anywhere; }
.pass .fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; padding: 10px 18px; }
.pass .fields .full { grid-column: 1 / -1; }
.pass .fields small { display: block; color: var(--muted); font-size: .75rem; }
.pass .fields div > span { font-weight: 700; overflow-wrap: anywhere; }
.pass .ring { display: flex; align-items: center; gap: 12px; padding: 4px 18px 8px; }
.pass .ring svg { flex: none; }
.pass .ring .num { font-size: 1.05rem; font-weight: 700; }
.pass .qr { border-block-start: 2px dashed var(--line); margin-block-start: 6px; padding: 16px 18px 18px; text-align: center; }
.pass .qr .box { display: inline-block; background: #fff; padding: 10px; border-radius: 14px; }
.pass .qr svg { display: block; inline-size: 210px; block-size: 210px; }
.pass .qr.dim .box { opacity: .35; }
.pass .qr small { display: block; color: var(--muted); margin-block-start: 6px; }
.offline { display: none; }
body.is-offline .offline { display: block; }

/* ---------- verify ---------- */
.verdict { border-radius: 20px; padding: 22px 18px; text-align: center; color: #fff; margin-block-end: 14px; }
.verdict.valid { background: #1f8a5b; } .verdict.bad { background: var(--red); } .verdict.warn { background: #b26a00; }
.verdict .big { font-size: 1.6rem; font-weight: 700; line-height: 1.3; }
.verdict .mark { inline-size: 64px; block-size: 64px; margin: 0 auto 8px; display: block; }
.verdict small { opacity: .9; }
.vperson { display: flex; gap: 14px; align-items: center; }
.vperson img, .vperson .ph0 { inline-size: 84px; block-size: 84px; border-radius: 16px; object-fit: cover; flex: none; background: var(--green-soft); }

/* ---------- scanner ---------- */
.scanbox { position: relative; border-radius: 18px; overflow: hidden; background: #000; aspect-ratio: 1 / 1; max-inline-size: 420px; margin-inline: auto; }
.scanbox video { inline-size: 100%; block-size: 100%; object-fit: cover; display: block; }
.scanbox .frame { position: absolute; inset: 18%; border: 3px solid rgba(255,255,255,.85); border-radius: 18px; box-shadow: 0 0 0 999px rgba(0,0,0,.25); }
.hidden { display: none !important; }

/* member rows (company request) */
.member { display: grid; gap: 6px; grid-template-columns: 1fr; border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-block-end: 8px; background: var(--surface); }
@media (min-width: 700px) { .member { grid-template-columns: 1.2fr 1.4fr 1fr auto; align-items: center; } }
.member input { min-block-size: 40px; }

footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 18px 12px 28px; }
@media print { .top, footer, .noprint { display: none !important; } body { background: #fff; } .pass { box-shadow: none; } }
.mt { margin-block-start: 22px; }
.center { text-align: center; }
.thumb { inline-size: 84px; block-size: 84px; border-radius: 14px; object-fit: cover; display: block; margin-block-end: 6px; }
.mt0 { margin-block-start: 10px; }
.sp { flex: 1; min-inline-size: 0; }
input.num { inline-size: 90px; }
a.item.req { display: block; color: var(--text); text-decoration: none; }
/* e-mail addresses: always LTR, one per line, never split inside the address */
.addr { display: inline-block; direction: ltr; unicode-bidi: isolate; overflow-wrap: anywhere; }
dd.emails .addr { display: block; font-size: .88rem; }
@media (max-width: 520px) { .top .wide { display: none; } }
[dir=rtl] dd.emails .addr { text-align: right; }

/* permit type picker on the request form */
.kinds { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-block-end: 6px; }
.kinds .choice { cursor: pointer; box-shadow: none; align-items: flex-start; }
.kinds .choice input { margin-block-start: 4px; accent-color: var(--green); }
.kinds .choice:has(input:checked) { border-color: var(--green); background: var(--green-soft); }

/* on-screen card: same security background as the PDF */
.pass .who, .pass .fields, .pass .ring {
  background-image: repeating-linear-gradient(-32deg, rgba(31, 107, 79, .035) 0 2px, transparent 2px 9px);
}
.pass .scope-tag { display: inline-block; margin-block-start: 4px; font-size: .78rem; font-weight: 700; color: var(--green); background: var(--green-soft); border-radius: 999px; padding: 2px 10px; }

.pass .bearer { margin: 0; padding: 8px 18px 0; box-sizing: border-box; inline-size: 100%; }
