:root {
  --navy: #232d3f; --navy2: #33405a; --orange: #d98a15; --orange2: #f2a63a;
  --bg: #eef1f6; --card: #ffffff; --text: #1b2130; --muted: #6b7484; --line: #e6e9ef;
  --ok: #1a9c5b; --bad: #d64545; --warn: #d98a15; --info: #3b5bdb; --radius: 18px;
  --shadow: 0 6px 20px rgba(35, 45, 63, .08);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { overflow-x: hidden; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: "Noto Kufi Arabic", "Segoe UI", Tahoma, system-ui, sans-serif; font-size: 15.5px; line-height: 1.55; }
body { padding-bottom: 84px; min-height: 100vh; }
header#top { display: flex; align-items: center; gap: 12px; color: #fff; padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
  background: linear-gradient(135deg, #1c2434 0%, #2b3750 60%, #35446a 100%); position: sticky; top: 0; z-index: 5; box-shadow: 0 4px 14px rgba(0,0,0,.18); }
header .brand { width: 42px; height: 42px; border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,.3); }
header .brand-text { display: flex; flex-direction: column; flex: 1; line-height: 1.3; min-width: 0; }
header .brand-text b { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
header small { color: #c9d2e3; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { background: #64748b; color: #fff; font-size: 12px; padding: 3px 10px; border-radius: 20px; white-space: nowrap; }
.badge.warn { background: var(--orange); }
main { padding: 16px 14px; max-width: 920px; margin: 0 auto; }
nav#nav { position: fixed; bottom: 0; right: 0; left: 0; background: rgba(255,255,255,.96); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
  display: flex; justify-content: space-around; padding: 6px 4px calc(8px + env(safe-area-inset-bottom)); z-index: 5; overflow-x: auto; scrollbar-width: none; }
nav#nav::-webkit-scrollbar { display: none; }
nav a { color: var(--muted); text-decoration: none; font-size: 11.5px; text-align: center; padding: 6px 8px; min-width: 60px; white-space: nowrap; border-radius: 14px; transition: .15s; }
nav a .ic { display: block; font-size: 21px; line-height: 1.2; }
nav a.active { color: var(--navy); background: #f1e6d3; font-weight: bold; }
h1 { font-size: 21px; margin: 2px 0 14px; color: var(--navy); font-weight: 700; }
h2 { font-size: 16.5px; margin: 16px 0 8px; color: var(--navy); }
.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); font-size: 13px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 5px; }
input, select, textarea { width: 100%; padding: 12px 14px; border: 1.5px solid #dfe3ea; border-radius: 12px; font: inherit; background: #fff; transition: .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(217,138,21,.15); }
input[type=checkbox] { width: 20px; height: 20px; vertical-align: middle; accent-color: var(--orange); }
textarea { min-height: 72px; }
button, .btn { font: inherit; border: 0; border-radius: 14px; padding: 12px 18px; background: var(--navy); color: #fff; cursor: pointer; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; transition: transform .1s, filter .15s; }
button:active, .btn:active { transform: scale(.98); }
button.big { width: 100%; padding: 20px; font-size: 20px; margin-top: 10px; border-radius: 18px; box-shadow: 0 8px 18px rgba(35,45,63,.18); }
button.ok { background: linear-gradient(135deg, #1a9c5b, #22b26a); } button.bad { background: linear-gradient(135deg, #d64545, #e25c5c); }
button.orange, .btn.orange { background: linear-gradient(135deg, #d98a15, #f2a63a); color: #fff; }
button.ghost, .btn.ghost { background: #eef1f6; color: var(--navy); font-weight: 600; }
button.sm, .btn.sm { padding: 8px 13px; font-size: 13px; border-radius: 10px; }
button:disabled { opacity: .5; cursor: default; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: 10px; }
.tile { background: #fff; border-radius: var(--radius); padding: 16px 12px; text-align: center; box-shadow: var(--shadow); color: var(--muted); font-size: 13px; }
.tile b { display: block; font-size: 30px; color: var(--navy); line-height: 1.2; margin-bottom: 4px; }
.tile.warn b { color: var(--orange); } .tile.bad b { color: var(--bad); } .tile.ok b { color: var(--ok); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 9px 7px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; background: #f7f8fb; }
tr:last-child td { border-bottom: 0; }
.tablewrap { overflow-x: auto; }
.tablewrap th, .tablewrap td { white-space: nowrap; }
.tablewrap td:nth-child(2) { white-space: normal; min-width: 150px; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; background: #eef1f6; color: var(--navy); white-space: nowrap; }
.pill.ok { background: #dcf5e7; color: #14653a; } .pill.bad { background: #fde3e3; color: #8f1d1d; } .pill.warn { background: #fdf0d5; color: #8a5a0b; } .pill.info { background: #e3e8fb; color: #2b3f9e; }
.list .item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.list .item:last-child { border-bottom: 0; }
.avatar { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; background: #e6e9ef; flex-shrink: 0; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.cam { position: relative; background: #0b0f17; border-radius: var(--radius); overflow: hidden; aspect-ratio: 3/4; max-height: 58vh; box-shadow: var(--shadow); }
.cam video, .cam img, .cam canvas { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam .frame { position: absolute; inset: 12% 18%; border: 3px dashed rgba(255,255,255,.55); border-radius: 50% / 40%; pointer-events: none; }
.cam .hint { position: absolute; bottom: 10px; right: 10px; left: 10px; text-align: center; color: #fff; background: rgba(0,0,0,.5); padding: 7px; border-radius: 10px; font-size: 13px; }
.status { padding: 11px 14px; border-radius: 12px; margin: 8px 0; font-size: 14px; display: flex; gap: 8px; align-items: center; }
.status.ok { background: #dcf5e7; color: #14653a; } .status.bad { background: #fde3e3; color: #8f1d1d; } .status.info { background: #e3e8fb; color: #2b3f9e; } .status.warn { background: #fdf0d5; color: #8a5a0b; }
#toast { position: fixed; bottom: 96px; left: 50%; transform: translateX(-50%); background: #111827; color: #fff; padding: 13px 20px; border-radius: 14px;
  max-width: 92vw; z-index: 20; font-size: 15px; box-shadow: 0 10px 30px rgba(0,0,0,.3); text-align: center; }
#toast.bad { background: var(--bad); } #toast.ok { background: var(--ok); }
.login { max-width: 400px; margin: 30px auto; text-align: center; padding: 26px 22px; }
.login img { width: 108px; border-radius: 26px; margin-bottom: 8px; box-shadow: 0 8px 22px rgba(35,45,63,.25); }
.login h1 { margin-bottom: 2px; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 10px; }
.photo-grid .card { padding: 8px; }
.photo-grid img { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 10px; }
.search { margin-bottom: 10px; }
.alert-item { border-right: 4px solid var(--orange); padding-right: 12px !important; }
.alert-item.seen { border-color: #cbd5e1; opacity: .65; }
.hero { background: linear-gradient(135deg, #232d3f, #3a4a6e); color: #fff; border-radius: var(--radius); padding: 18px; margin-bottom: 14px; box-shadow: var(--shadow); }
.hero .muted { color: #c9d2e3; }
.hero b.time { font-size: 28px; display: block; }
.switch { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.switch:last-child { border-bottom: 0; }
.switch span { flex: 1; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips button { border-radius: 20px; padding: 8px 14px; font-size: 13px; }
.emptystate { text-align: center; color: var(--muted); padding: 24px 10px; }
.emptystate .ic { font-size: 40px; display: block; margin-bottom: 6px; }
@media (min-width: 700px) { nav a { font-size: 12.5px; min-width: 80px; } main { padding: 22px; } }
@media print { header, nav, button, .noprint, #toast { display: none !important; } body { background: #fff; padding: 0; } .card { box-shadow: none; border: 1px solid #ddd; } }

nav a { position: relative; }
nav a .dot { position: absolute; top: 2px; left: 8px; background: var(--bad); color: #fff; font-size: 10px; min-width: 16px; height: 16px; border-radius: 8px; display: flex; align-items: center; justify-content: center; padding: 0 3px; }

/* كشف الصرفيات — طباعة على فورمة الشركة (A4) */
.print-root { background: #9aa1ad; padding: 12px 0; }
.a4 { width: 210mm; min-height: 297mm; margin: 0 auto 12px; background: #fff url("/letterhead.jpg") no-repeat center top; background-size: 210mm 297mm; position: relative; box-shadow: 0 6px 24px rgba(0,0,0,.25); color: #111; }
.a4-body { position: absolute; top: 42mm; bottom: 22mm; right: 14mm; left: 14mm; font-size: 11.5px; }
.ptitle { font-size: 17px; font-weight: 700; color: #232d3f; text-align: center; margin: 0 0 8px; border-bottom: 2px solid #d98a15; padding-bottom: 4px; }
table.meta { width: 100%; border-collapse: collapse; margin-bottom: 8px; font-size: 11px; }
table.meta td { border: 1px solid #cfd4dc; padding: 4px 6px; }
table.rep { width: 100%; border-collapse: collapse; margin-bottom: 8px; font-size: 11px; }
table.rep th, table.rep td { border: 1px solid #9aa1ad; padding: 3px 5px; text-align: right; white-space: normal; background: #fff; }
table.rep th { background: #eef1f6; color: #232d3f; }
table.rep tr.tot td { font-weight: 700; background: #fdf0d5; }
table.rep.grand td { font-size: 12px; font-weight: 700; }
.sigs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.sig { border: 1px solid #cfd4dc; border-radius: 6px; padding: 6px; min-height: 52px; text-align: center; font-size: 10.5px; }
.sig-role { font-weight: 700; color: #232d3f; } .sig-name { margin-top: 3px; } .sig-date { color: #6b7484; font-size: 9.5px; }
.paid { margin-top: 10px; text-align: center; font-weight: 700; color: #14653a; border: 2px dashed #1a9c5b; padding: 6px; border-radius: 8px; }
.rgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.rgrid figure { margin: 0; border: 1px solid #cfd4dc; border-radius: 6px; padding: 4px; text-align: center; page-break-inside: avoid; }
.rgrid img { width: 100%; max-height: 100mm; object-fit: contain; }
.rgrid figcaption { font-size: 10px; color: #333; margin-top: 3px; }
@media print {
  @page { size: A4; margin: 0; }
  .print-root { background: none; padding: 0; }
  .a4 { box-shadow: none; margin: 0; page-break-after: always; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .a4:last-child { page-break-after: auto; }
  main { padding: 0; max-width: none; } body { padding: 0; }
}
