:root {
  --bg: #f4f1ea;
  --surface: #ffffff;
  --ink: #1d2a2f;
  --muted: #6b7678;
  --line: #e2ddd2;
  --brand: #0f5c55;
  --brand-ink: #ffffff;
  --accent: #c9822b;
  --ok: #2e7d4f;
  --warn: #b5541c;
  --danger: #a3302a;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
  background: var(--bg); color: var(--ink);
  font-size: 18px; line-height: 1.5;
}
a { color: var(--brand); }
.wrap { max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--brand); color: var(--brand-ink); padding: 12px 20px;
}
.topbar h1 { font-size: 22px; margin: 0; font-weight: 800; }
.topbar a { color: var(--brand-ink); text-decoration: none; opacity: .85; font-size: 15px; }
.topbar .pill { background: rgba(255,255,255,.15); padding: 4px 12px; border-radius: 99px; font-size: 16px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

.btn {
  font: inherit; font-weight: 700; border: 0; border-radius: 12px; cursor: pointer;
  padding: 12px 20px; background: var(--brand); color: var(--brand-ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn.big { font-size: 26px; padding: 22px 30px; }
.btn.ok { background: var(--ok); }
.btn.warn { background: var(--warn); }
.btn.ghost { background: transparent; color: var(--brand); border: 2px solid var(--brand); }
.btn.danger { background: var(--danger); }
.btn.block { width: 100%; }

input[type=text], input[type=password], input[type=number], textarea, select {
  font: inherit; width: 100%; padding: 12px 14px; border: 2px solid var(--line);
  border-radius: 12px; background: #fff; color: var(--ink);
}
input:focus, textarea:focus { outline: none; border-color: var(--brand); }
.search { font-size: 26px; padding: 16px 20px; }
label { display: block; font-weight: 700; margin: 10px 0 4px; }
.muted { color: var(--muted); }
.small { font-size: 15px; }

.badge { display: inline-block; padding: 2px 12px; border-radius: 99px; font-size: 15px; font-weight: 700; background: var(--line); }
.badge.new { background: #e8eef0; color: #345; }
.badge.waiting { background: #fbefd9; color: #8a5a12; }
.badge.called { background: #dcefe9; color: var(--brand); }
.badge.done { background: #dff1e4; color: var(--ok); }
.badge.skipped { background: #f7e0d8; color: var(--warn); }

.result { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.result + .result { margin-top: 12px; }
.result h3 { margin: 0 0 4px; font-size: 22px; }
.cards-list { margin: 6px 0 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.cards-list li { background: var(--bg); border-radius: 8px; padding: 2px 10px; font-size: 16px; }
.cards-list li { cursor: pointer; }
.cards-list li:hover { outline: 2px solid var(--brand); }
.cards-list li.got { text-decoration: line-through; color: var(--muted); }
.cards-list li.ref { background: #f7e0d8; color: var(--warn); }
.checks .rowx { display: flex; gap: 8px; align-items: center; }
.checks .rowx label { flex: 1; }
.checks .ref-btn { font: inherit; font-size: 15px; border: 2px solid var(--warn); color: var(--warn); background: #fff; border-radius: 10px; padding: 8px 10px; cursor: pointer; }
.checks label.refused { background: #f7e0d8; opacity: .8; }
table.rep { width: 100%; border-collapse: collapse; background: #fff; font-size: 16px; }
table.rep th, table.rep td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: top; }
table.rep th { background: var(--bg); position: sticky; top: 0; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; }
.filters .btn { padding: 8px 14px; font-size: 16px; }
.filters .btn.on { background: var(--ink); color: #fff; border-color: var(--ink); }

.stat .n { font-size: 40px; font-weight: 800; color: var(--brand); line-height: 1.1; }
.stat .l { color: var(--muted); font-size: 15px; }

/* نافذة رقم الدور */
.modal { position: fixed; inset: 0; background: rgba(20,30,32,.6); display: none; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal.open { display: flex; }
.modal .box { background: #fff; border-radius: 22px; padding: 30px; text-align: center; width: min(460px, 100%); }
.ticket-num { font-size: 120px; font-weight: 800; color: var(--brand); line-height: 1; margin: 10px 0; }

/* المكتب */
.desk-now { text-align: center; padding: 30px 18px; }
.desk-now .ticket-num { font-size: 140px; }
.checks { text-align: right; margin: 16px auto; max-width: 520px; }
.checks label { display: flex; gap: 12px; align-items: center; font-weight: 500; font-size: 22px; padding: 10px 14px; border: 2px solid var(--line); border-radius: 12px; margin: 8px 0; cursor: pointer; }
.checks input { width: 26px; height: 26px; accent-color: var(--ok); }
.checks label.got { opacity: .5; text-decoration: line-through; }
.actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 22px; border-radius: 12px; display: none; z-index: 60; }
.toast.show { display: block; }
.toast.err { background: var(--danger); }

/* ===== الشاشة ===== */
/* ===== الشاشة — الألوان كلها متغيرات، وكل «ثيم» يغيّرها فقط ===== */
body.screen {
  /* الافتراضي: فاتح أحمر وأبيض */
  --s-bg: #f5f3ef; --s-ink: #1c2430; --s-muted: #6b7380;
  --s-tile: #ffffff; --s-tile-line: #e6e1d8; --s-num: #c8102e; --s-label: #1c2430;
  --s-accent: #c8102e; --s-accent-ink: #ffffff; --s-head: #c8102e; --s-head-ink: #ffffff;
  --s-flash: #c8102e; --s-flash-ink: #ffffff; --s-over: rgba(255,255,255,.97); --s-over-num: #c8102e;
  --s-shadow: 0 .6vh 2vh rgba(28,36,48,.08);
  background: var(--s-bg); color: var(--s-ink); overflow: hidden; height: 100vh;
}
body.screen[data-theme="maroon"] {
  --s-bg: #f7f2ef; --s-ink: #2a1a1f; --s-muted: #7a6a6f;
  --s-tile: #ffffff; --s-tile-line: #eadfdb; --s-num: #8a1538; --s-label: #2a1a1f;
  --s-accent: #8a1538; --s-accent-ink: #ffffff; --s-head: #8a1538; --s-head-ink: #ffffff;
  --s-flash: #8a1538; --s-flash-ink: #fff; --s-over: rgba(138,21,56,.97); --s-over-num: #ffffff;
}
body.screen[data-theme="navy"] {
  --s-bg: #0f1d33; --s-ink: #eef2f8; --s-muted: #9fb0c8;
  --s-tile: #18294a; --s-tile-line: #22365e; --s-num: #ffffff; --s-label: #c9d5e8;
  --s-accent: #f2b544; --s-accent-ink: #0f1d33; --s-head: #0b1628; --s-head-ink: #ffffff;
  --s-flash: #f2b544; --s-flash-ink: #0f1d33; --s-over: rgba(11,22,40,.97); --s-over-num: #f2b544;
  --s-shadow: none;
}
body.screen[data-theme="blue"] {
  --s-bg: #eef3f9; --s-ink: #13233a; --s-muted: #5f6f85;
  --s-tile: #ffffff; --s-tile-line: #d9e3ef; --s-num: #0b5cad; --s-label: #13233a;
  --s-accent: #0b5cad; --s-accent-ink: #ffffff; --s-head: #0b5cad; --s-head-ink: #ffffff;
  --s-flash: #0b5cad; --s-flash-ink: #fff; --s-over: rgba(255,255,255,.97); --s-over-num: #0b5cad;
}
body.screen[data-theme="black"] {
  --s-bg: #000000; --s-ink: #ffffff; --s-muted: #a0a0a0;
  --s-tile: #111111; --s-tile-line: #2a2a2a; --s-num: #ffd400; --s-label: #ffffff;
  --s-accent: #00d26a; --s-accent-ink: #000; --s-head: #000; --s-head-ink: #ffffff;
  --s-flash: #ffd400; --s-flash-ink: #000; --s-over: rgba(0,0,0,.96); --s-over-num: #ffd400;
  --s-shadow: none;
}
.screen-head { display: flex; justify-content: space-between; align-items: center; padding: 1.6vh 3vw; background: var(--s-head); color: var(--s-head-ink); }
.screen-head h1 { margin: 0; font-size: 4.2vh; font-weight: 800; }
.screen-head .clock { font-size: 4.2vh; font-weight: 700; font-variant-numeric: tabular-nums; }
.screen-main { display: grid; grid-template-columns: 1fr 26vw; gap: 2vw; padding: 2.5vh 3vw 0; height: 76vh; }
.desks { display: grid; gap: 2vh; grid-auto-rows: 1fr; }
.desk-tile { background: var(--s-tile); border: 2px solid var(--s-tile-line); box-shadow: var(--s-shadow); border-radius: 2vh;
  display: flex; align-items: center; justify-content: space-between; padding: 0 3vw; transition: background .3s, color .3s; }
.desk-tile .dn { font-size: 5vh; font-weight: 700; color: var(--s-label); }
.desk-tile .tn { font-size: 14vh; font-weight: 800; color: var(--s-num); font-variant-numeric: tabular-nums; }
.desk-tile.flash { background: var(--s-flash); border-color: var(--s-flash); animation: pulse .6s 4; }
.desk-tile.flash .dn, .desk-tile.flash .tn { color: var(--s-flash-ink); }
@keyframes pulse { 50% { transform: scale(1.02); } }
.side { background: var(--s-tile); border: 2px solid var(--s-tile-line); box-shadow: var(--s-shadow); border-radius: 2vh; padding: 2.5vh 2vw; display: flex; flex-direction: column; }
.side h2 { margin: 0 0 1vh; font-size: 3vh; color: var(--s-muted); font-weight: 700; }
.recent div { display: flex; justify-content: space-between; font-size: 4vh; padding: .7vh 0; border-bottom: 1px solid var(--s-tile-line); }
.recent b { font-weight: 800; color: var(--s-num); font-variant-numeric: tabular-nums; }
.side .wait { margin-top: auto; text-align: center; color: var(--s-muted); font-size: 2.6vh; }
.side .wait .n { font-size: 9vh; font-weight: 800; line-height: 1.1; color: var(--s-ink); }
.progress { height: 1.4vh; background: var(--s-tile-line); border-radius: 99px; overflow: hidden; margin: 1vh 0 .5vh; }
.progress > i { display: block; height: 100%; background: var(--s-accent); width: 0; transition: width .5s; }
.screen-foot { text-align: center; font-size: 2.6vh; color: var(--s-muted); padding-top: 2vh; }
.announce { position: fixed; inset: 0; background: var(--s-over); display: none; align-items: center; justify-content: center; flex-direction: column; z-index: 40; }
.announce.show { display: flex; }
.announce .t1 { font-size: 7vh; color: var(--s-over-num); font-weight: 700; opacity: .8; }
.announce .t2 { font-size: 34vh; font-weight: 800; line-height: 1; color: var(--s-over-num); font-variant-numeric: tabular-nums; }
.announce .t3 { font-size: 9vh; font-weight: 800; color: var(--s-over-num); }
/* زر اختيار الألوان — يظهر عند تحريك الماوس فقط */
.theme-pick { position: fixed; bottom: 1.5vh; left: 1.5vw; display: flex; gap: 8px; z-index: 30; opacity: 0; transition: opacity .3s; }
body.screen:hover .theme-pick { opacity: 1; }
.theme-pick button { width: 34px; height: 34px; border-radius: 50%; border: 3px solid #fff; cursor: pointer; box-shadow: 0 0 0 1px #999; }
.theme-pick button.on { box-shadow: 0 0 0 3px #333; }
.sound-gate { position: fixed; inset: 0; background: rgba(0,0,0,.75); display: flex; align-items: center; justify-content: center; z-index: 70; cursor: pointer; font-size: 4vh; }

/* طباعة الإيصال */
.slip { display: none; }
@media print {
  body * { visibility: hidden; }
  .slip, .slip * { visibility: visible; }
  .slip { display: block; position: absolute; top: 0; right: 0; left: 0; text-align: center; font-family: 'Tajawal', sans-serif; }
  .slip .ticket-num { font-size: 90px; color: #000; }
}
@media (max-width: 700px) {
  .ticket-num { font-size: 90px; }
  .desk-now .ticket-num { font-size: 100px; }
}

.formtag { display: inline-block; background: #fbefd9; color: #7a4e0e; border-radius: 8px; padding: 2px 10px; font-size: 16px; font-weight: 700; margin: 2px 0 4px; }
.formtag.big { font-size: 22px; padding: 6px 16px; margin: 10px 0; }
.cardmeta { display: block; font-size: 14px; color: var(--muted); direction: rtl; }

.received { background: #dff1e4; color: var(--ok); font-weight: 800; font-size: 20px; border-radius: 10px; padding: 6px 12px; margin: 6px 0; }
.result.is-done { border: 2px solid var(--ok); background: #f6fbf7; }

.filters3 { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.filters3 > div { min-width: 140px; }
.filters3 .grow { flex: 1; min-width: 240px; }
.filters3 select, .filters3 input { font-size: 22px; padding: 12px 14px; }
.filters3 label { margin-top: 0; }
