/* ============================================================
   نظام الاستعلام — مراقبة التربية والتعليم سوق الخميس إمسيحل
   ============================================================ */

:root {
  --navy: #7a5c0f;
  --navy-dark: #4a3708;
  --navy-mid: #c9a227;
  --gold: #d4af37;
  --gold-bright: #f0d060;
  --gold-soft: #fff8e1;
  --gold-mid: #f5e6b0;
  --blue-light: #fff6d6;
  --blue-info: #fef3c7;
  --blue-border: #e6c96a;
  --text: #2a2110;
  --text-muted: #6b5a3a;
  --white: #ffffff;
  --gray-bg: #fff9eb;
  --input-bg: #fffdf5;
  --shadow: 0 8px 28px rgba(122, 92, 15, 0.14);
  --radius: 14px;
  --font: "Tajawal", "Segoe UI", Tahoma, sans-serif;
}

*,
*::before,
*::after {
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: hidden;
  max-width: 100%;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  font-family: var(--font);
  background:
    radial-gradient(ellipse at top, rgba(240, 208, 96, 0.35), transparent 55%),
    linear-gradient(180deg, #fffdf5 0%, #f7e7b2 45%, #efe0a0 100%);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -ms-flex-direction: column;
  flex-direction: column;
  direction: rtl;
  line-height: 1.7;
  overflow-x: hidden;
  max-width: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* خلفية ثابتة غير مدعومة جيداً في iOS Safari */
@supports not (-webkit-touch-callout: none) {
  body {
    background-attachment: fixed;
  }
}

img,
video {
  max-width: 100%;
  height: auto;
}

svg {
  max-width: 100%;
  flex-shrink: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button,
input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

a {
  color: var(--navy);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

a:hover {
  color: var(--navy-dark);
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: linear-gradient(135deg, #5c4508 0%, #8a6a12 42%, #c9a227 78%, #e0c35a 100%);
  color: #fffdf5;
  padding: 0.75rem 1.25rem;
  padding-top: max(0.75rem, env(safe-area-inset-top));
  box-shadow: 0 4px 18px rgba(74, 55, 8, 0.32);
  border-bottom: 3px solid #f0d060;
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-seal {
  width: 100px;
  height: 100px;
  border-radius: 0;
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: none;
  overflow: hidden;
  padding: 0;
}

.logo-seal img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.28));
}

.header-text h1 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.15rem;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.header-text p {
  font-size: 0.9rem;
  opacity: 0.92;
  font-weight: 500;
}

/* ---------- Main ---------- */
.site-main {
  flex: 1;
  padding: 2.5rem 1.25rem 3rem;
}

.container {
  max-width: 640px;
  margin: 0 auto;
}

.page-title {
  text-align: center;
  color: var(--navy);
  font-size: clamp(1.15rem, 2.8vw, 1.4rem);
  font-weight: 800;
  margin-bottom: 0.55rem;
  line-height: 1.55;
}

.page-desc {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.94rem;
  margin-bottom: 1.1rem;
  line-height: 1.7;
}

.btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin: 0 auto 1.75rem;
  padding: 0.45rem 1.35rem;
  border: 1.5px solid var(--navy-mid);
  color: var(--navy);
  background: transparent;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.btn-outline:hover {
  background: linear-gradient(180deg, #e0c35a, #8a6a12);
  color: #fffdf5;
  border-color: #8a6a12;
}

.btn-wrap {
  text-align: center;
}

/* ---------- Search Card ---------- */
.search-card {
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 16px 40px rgba(74, 55, 8, 0.12);
  border: 1px solid rgba(201, 162, 39, 0.32);
  padding: 0 1.4rem 1.35rem;
  margin-bottom: 1.15rem;
  overflow: hidden;
  position: relative;
}

.search-card::before {
  content: "";
  display: block;
  height: 4px;
  margin: 0 -1.4rem 0;
  background: linear-gradient(90deg, #5c4508, #c9a227, #f0d060, #8a6a12);
}

.search-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 1rem 0 0.9rem;
  border-bottom: 1px solid rgba(201, 162, 39, 0.28);
  margin-bottom: 1rem;
}

.search-card-title {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.search-card-icon {
  width: 40px;
  height: 40px;
  min-width: 40px;
  max-width: 40px;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #e0c35a, #8a6a12);
  color: #fffdf5;
  box-shadow: 0 4px 12px rgba(122, 92, 15, 0.25);
  flex: 0 0 40px;
  overflow: hidden;
}

.search-card-icon svg {
  width: 20px !important;
  height: 20px !important;
  display: block;
}

.search-card-copy {
  min-width: 0;
}

.search-card-title h3,
.search-card-copy h3 {
  margin: 0;
  color: var(--navy);
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.35;
}

.search-card-title p,
.search-card-copy p {
  margin: 0.15rem 0 0;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.4;
}

.btn-clarif {
  margin: 0 !important;
  padding: 0.42rem 1rem;
  font-size: 0.84rem;
  background: #fffdf5;
  white-space: nowrap;
}

.input-shell {
  display: flex;
  align-items: stretch;
  border: 1.5px solid #d9cfb0;
  border-radius: 12px;
  background: #fffdf8;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-shell:focus-within {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.22);
  background: #fff;
}

.input-prefix {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  padding: 0 0.65rem;
  background: linear-gradient(180deg, #fff6d6, #f0e2a8);
  color: var(--navy-dark);
  font-weight: 800;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  border-left: 1px solid rgba(201, 162, 39, 0.35);
}

.input-shell input {
  border: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  flex: 1;
  min-width: 0;
  letter-spacing: 0.08em;
  font-size: 1.08rem;
}

#group-financial-number .input-shell input {
  letter-spacing: normal;
  font-size: 1.02rem;
}

.field-hint {
  margin: 0.4rem 0 0;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 500;
}

.form-group {
  margin-bottom: 1.15rem;
}

.form-group label,
.field-label {
  display: block;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.nationality-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.nat-option {
  cursor: pointer;
  margin: 0 !important;
}

.nat-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.nat-option span {
  display: block;
  text-align: center;
  padding: 0.78rem 0.5rem;
  border: 1.5px solid #d9cfb0;
  border-radius: 12px;
  background: #fffdf8;
  color: var(--text-muted);
  font-weight: 700;
  transition: border-color 0.2s, background 0.2s, color 0.2s, box-shadow 0.2s;
}

.nat-option:hover span {
  border-color: var(--gold);
  color: var(--navy);
}

.nat-option input:checked + span {
  border-color: #c9a227;
  background: linear-gradient(180deg, #fff8e1, #f3e4ad);
  color: var(--navy-dark);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.18), 0 4px 12px rgba(122, 92, 15, 0.1);
}

.form-group input {
  width: 100%;
  padding: 0.85rem 1rem;
  background: var(--input-bg);
  border: 1.5px solid #d5dde8;
  border-radius: 10px;
  font-family: inherit;
  font-size: 1.15rem;
  letter-spacing: 0.12em;
  text-align: center;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  direction: ltr;
  -webkit-appearance: none;
  -moz-appearance: textfield;
  appearance: none;
}

.form-group input::-webkit-outer-spin-button,
.form-group input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.form-group input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.28);
  background: var(--white);
}

.form-group input.is-invalid {
  border-color: #c0392b;
  box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.12);
}

.btn-search {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.92rem 1.2rem;
  margin-top: 0.35rem;
  background: linear-gradient(180deg, #e8ce6a, #c9a227 42%, #8a6a12);
  color: #fffdf5;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-size: 1.08rem;
  font-weight: 800;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: transform 0.15s, box-shadow 0.2s, filter 0.2s;
  box-shadow: 0 8px 18px rgba(122, 92, 15, 0.28);
}

.btn-search:hover {
  filter: brightness(1.05);
  box-shadow: 0 10px 22px rgba(122, 92, 15, 0.36);
  transform: translateY(-1px);
}

.btn-search:active {
  transform: translateY(1px);
}

.btn-search svg {
  width: 20px !important;
  height: 20px !important;
  display: block;
}

/* ---------- Info Banner ---------- */
.info-banner {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: linear-gradient(180deg, #fff8e1, #fef3c7);
  border: 1px solid var(--blue-border);
  border-radius: 14px;
  padding: 0.9rem 1.05rem;
  color: var(--navy);
  font-size: 0.93rem;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(122, 92, 15, 0.06);
}

.info-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(180deg, #e0c35a, #8a6a12);
  color: #fffdf5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  flex-shrink: 0;
  font-style: italic;
  font-family: Georgia, serif;
}

/* ---------- Maintenance Card (وضع الصيانة) ---------- */
.maintenance-card {
  background: #ffffff;
  border-radius: 18px;
  border: 1px solid rgba(212, 175, 55, 0.35);
  border-top: 4px solid var(--gold);
  box-shadow: 0 14px 36px rgba(74, 55, 8, 0.12);
  padding: 2.2rem 1.5rem 1.8rem;
  text-align: center;
  animation: fadeUp 0.35s ease;
}

.maintenance-icon {
  width: 92px;
  height: 92px;
  margin: 0 auto 1.1rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--navy-dark);
  background: radial-gradient(circle at 30% 25%, #fff6d6, #f0d060 70%, #c9a227);
  box-shadow: inset 0 0 0 6px rgba(255, 255, 255, 0.65), 0 10px 24px rgba(122, 92, 15, 0.22);
  animation: maintPulse 2.6s ease-in-out infinite;
}

@keyframes maintPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.maintenance-title {
  color: var(--navy-dark);
  font-size: 1.3rem;
  margin-bottom: 0.85rem;
}

.maintenance-text {
  max-width: 620px;
  margin: 0 auto;
  color: var(--text);
  font-size: 1rem;
  line-height: 1.9;
}

.maintenance-note {
  margin-top: 1.15rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
}

/* ---------- Result Card ---------- */
.result-card {
  background: #ffffff;
  border-radius: 18px;
  box-shadow: 0 14px 36px rgba(74, 55, 8, 0.12);
  padding: 1.4rem 1.3rem;
  margin-bottom: 1.15rem;
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-top: 4px solid var(--gold);
  animation: fadeUp 0.35s ease;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.result-card.not-found {
  border-top-color: #c0392b;
}

.result-header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 1.15rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid #e8eef5;
}

.result-header .badge {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--blue-light);
  color: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
}

.result-header h3 {
  font-size: 1.1rem;
  color: var(--navy);
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.result-item {
  background: var(--gray-bg);
  border-radius: 10px;
  padding: 0.9rem 1rem;
}

.result-item.full {
  grid-column: 1 / -1;
}

.result-item .label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.result-item .value {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--navy);
}

.result-item .value.highlight {
  font-size: 1.6rem;
  color: var(--navy-mid);
}

.result-actions {
  margin-top: 1.35rem;
  padding-top: 1.1rem;
  border-top: 1px solid rgba(212, 175, 55, 0.35);
  text-align: center;
}

.btn-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.75rem 1.5rem;
  background: linear-gradient(180deg, #e0c35a, #c9a227 45%, #8a6a12);
  color: #fffdf5 !important;
  border-radius: 10px;
  font-weight: 700;
  font-size: 1rem;
  box-shadow: 0 4px 12px rgba(122, 92, 15, 0.28);
  transition: filter 0.2s, transform 0.15s;
}

.btn-back:hover {
  filter: brightness(1.06);
  color: #fffdf5 !important;
}

.years-table-wrap {
  margin-top: 1.15rem;
  overflow-x: auto;
}

.years-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.years-table th,
.years-table td {
  padding: 0.75rem 0.65rem;
  border-bottom: 1px solid #e8eef5;
  text-align: center;
}

.years-table th {
  background: var(--blue-light);
  color: var(--navy);
  font-weight: 700;
}

.years-table .year-cell,
.years-table .months-cell {
  font-weight: 800;
  color: var(--navy-mid);
  font-size: 1.1rem;
}

.years-table tfoot td {
  background: #f0f6fb;
  font-weight: 700;
  color: var(--navy);
  border-bottom: none;
}

.alert-error {
  background: #fdecea;
  border: 1px solid #f5c6cb;
  color: #922b21;
  border-radius: 12px;
  padding: 0.95rem 1.1rem;
  margin-bottom: 1.25rem;
  text-align: center;
  font-weight: 600;
  animation: fadeUp 0.35s ease;
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  inset: 0;
  background: rgba(8, 42, 77, 0.55);
  display: none;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--white);
  border-radius: var(--radius);
  max-width: 480px;
  width: 100%;
  padding: 1.5rem;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
  animation: fadeUp 0.25s ease;
}

.modal h3 {
  color: var(--navy);
  margin-bottom: 1rem;
  font-size: 1.15rem;
}

.modal-body {
  color: var(--text);
  font-size: 0.95rem;
  white-space: pre-line;
  margin-bottom: 1.25rem;
}

.modal-close {
  width: 100%;
  padding: 0.7rem;
  background: linear-gradient(180deg, #e0c35a, #8a6a12);
  color: #fffdf5;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
}

.modal-close:hover {
  filter: brightness(1.1);
}

.clarif-modal {
  max-width: 520px;
  border: 1px solid rgba(201, 162, 39, 0.4);
  border-top: 5px solid var(--gold);
}

.clarif-list {
  background: #fffdf5;
  border: 1px solid rgba(201, 162, 39, 0.28);
  border-radius: 10px;
  padding: 0.9rem 1rem;
  line-height: 1.9;
}

/* Custom Confirm Modal Styles */
.confirm-modal {
  text-align: center;
  max-width: 400px;
}

.confirm-modal .modal-icon {
  width: 64px;
  height: 64px;
  background: #fdecea;
  color: #c0392b;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem;
}

.confirm-modal .modal-icon svg {
  width: 32px;
  height: 32px;
}

.confirm-modal h3 {
  color: #922b21;
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
}

.confirm-modal .modal-body {
  color: #6b5a3a;
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.confirm-modal .modal-actions {
  display: flex;
  gap: 0.75rem;
}

.confirm-modal .modal-actions button {
  flex: 1;
  padding: 0.8rem;
  border-radius: 12px;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.confirm-modal .btn-danger {
  background: linear-gradient(180deg, #e74c3c, #c0392b);
  color: white;
  box-shadow: 0 4px 12px rgba(192, 57, 43, 0.2);
}

.confirm-modal .btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(192, 57, 43, 0.3);
  filter: brightness(1.1);
}

.confirm-modal .btn-secondary {
  background: #f8f9fa;
  color: #5d6d7e;
  border: 1px solid #d5dbdb !important;
}

.confirm-modal .btn-secondary:hover {
  background: #ebedef;
  color: #2c3e50;
  transform: translateY(-2px);
}

#btn-bulk-delete {
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(192, 57, 43, 0.2);
}

#btn-bulk-delete:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(192, 57, 43, 0.3);
  filter: brightness(1.1);
}

.data-table th:last-child,
.data-table td:last-child {
  text-align: center;
}

.data-table input[type="checkbox"] {
  cursor: pointer;
  width: 20px;
  height: 20px;
  accent-color: var(--navy);
  margin: 0;
  vertical-align: middle;
}

.data-table th input[type="checkbox"] {
  transform: scale(1.1);
}

/* ---------- Footer ---------- */
.site-footer {
  position: sticky;
  bottom: 0;
  z-index: 1000;
  background: linear-gradient(180deg, #fff6d6, #f0d98a);
  border-top: 2px solid var(--gold);
  padding: 1.25rem 1.5rem;
  padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
  text-align: center;
  color: var(--navy-dark);
  font-size: 0.88rem;
}

.site-footer .copy {
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.site-footer .disclaimer {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.site-footer .developer {
  font-weight: 700;
  font-size: 0.84rem;
  color: var(--navy-dark);
  margin-bottom: 0.35rem;
  letter-spacing: 0.2px;
}

.site-footer .developer::before,
.site-footer .developer::after {
  content: "•";
  color: var(--gold);
  margin: 0 0.5rem;
}

/* ---------- Inquiry page: no page scrollbars ---------- */
html.page-inquiry,
body.page-inquiry {
  height: 100%;
  max-width: 100%;
}

body.page-inquiry {
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -ms-flex-direction: column;
  flex-direction: column;
}

body.page-inquiry .site-header {
  flex-shrink: 0;
}

body.page-inquiry .site-footer {
  flex-shrink: 0;
  padding: 0.85rem 1.25rem;
}

body.page-inquiry .site-main {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 1.25rem 1.25rem 1rem;
}

body.page-inquiry .container {
  max-height: 100%;
}

body.page-inquiry .page-title {
  font-size: 1.25rem;
  margin-bottom: 0.45rem;
}

body.page-inquiry .page-desc {
  margin-bottom: 0.75rem;
  font-size: 0.92rem;
}

body.page-inquiry .btn-outline {
  margin-bottom: 1rem;
}

body.page-inquiry .search-card {
  padding: 0 1.2rem 1.15rem;
  margin-bottom: 0.9rem;
}

body.page-inquiry .search-card-head {
  padding: 0.9rem 0 0.8rem;
  margin-bottom: 0.9rem;
}

body.page-inquiry .search-card-icon {
  width: 38px;
  height: 38px;
  min-width: 38px;
  max-width: 38px;
  flex-basis: 38px;
}

body.page-inquiry .form-group {
  margin-bottom: 0.85rem;
}

body.page-inquiry .info-banner {
  margin-bottom: 0;
}

body.page-inquiry .result-card {
  max-height: calc(100vh - 220px);
  max-height: calc(100dvh - 220px);
  overflow: hidden;
}

body.page-inquiry .years-table-wrap {
  overflow: hidden;
}

/* ---------- Admin ---------- */
.admin-wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.25rem;
}

.admin-card {
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 10px 28px rgba(74, 55, 8, 0.1);
  border: 1px solid rgba(212, 175, 55, 0.28);
  padding: 1.4rem 1.35rem;
  margin-bottom: 1.35rem;
}

.admin-card h2 {
  color: var(--navy);
  font-size: 1.2rem;
  margin-bottom: 1rem;
}

.admin-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.85rem;
  align-items: end;
}

.admin-form .form-group {
  margin-bottom: 0;
}

.admin-form label {
  font-size: 0.85rem;
}

.admin-form input,
.admin-form select {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1.5px solid #d5dde8;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  background: var(--input-bg);
  outline: none;
}

.num-stepper {
  display: flex;
  align-items: stretch;
  width: 100%;
  border: 1.5px solid #d5dde8;
  border-radius: 8px;
  overflow: hidden;
  background: var(--input-bg);
}

.num-stepper:focus-within {
  border-color: var(--navy-mid);
}

.num-stepper input[type="number"] {
  border: none !important;
  border-radius: 0 !important;
  text-align: center;
  min-width: 0;
  flex: 1;
  -moz-appearance: textfield;
}

.num-stepper input[type="number"]::-webkit-outer-spin-button,
.num-stepper input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.num-step {
  width: 2.1rem;
  min-width: 2.1rem;
  border: none;
  background: linear-gradient(180deg, #fff6d6, #f0e2a8);
  color: var(--navy-dark);
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.num-step:hover {
  background: linear-gradient(180deg, #e8ce6a, #c9a227);
  color: #fffdf5;
}

.num-step:active {
  filter: brightness(0.95);
}

.settings-textarea {
  width: 100%;
  min-height: 160px;
  padding: 0.85rem 1rem;
  border: 1.5px solid #d5dde8;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.98rem;
  line-height: 1.8;
  background: var(--input-bg);
  color: var(--text);
  outline: none;
  resize: vertical;
}

.settings-textarea:focus {
  border-color: var(--navy-mid);
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.22);
}

.import-hint {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  line-height: 1.7;
}

.import-hint a {
  font-weight: 700;
}

.import-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.import-preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
}

.import-preview-table input[type="text"],
.import-preview-table input[type="number"] {
  width: 100%;
  min-width: 4.5rem;
  padding: 0.35rem 0.4rem;
  border: 1px solid #d5dde8;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.85rem;
  background: #fff;
}

.import-preview-table .row-ok td {
  background: #f3fbf6;
}

.import-preview-table .row-warn td {
  background: #fff8e1;
}

.import-preview-table .row-err td {
  background: #fdecea;
}

.import-preview-table .status-cell {
  font-size: 0.8rem;
  font-weight: 600;
  max-width: 220px;
}

.import-form input[type="file"] {
  flex: 1;
  min-width: 220px;
  padding: 0.55rem;
  border: 1.5px dashed var(--blue-border);
  border-radius: 8px;
  background: var(--gold-soft);
  font-family: inherit;
}

.admin-form input:focus,
.admin-form select:focus {
  border-color: var(--navy-mid);
}

.admin-form input:disabled,
.admin-form input[readonly][aria-disabled="true"] {
  background: #ece7d8;
  color: #8a7a5a;
  cursor: not-allowed;
  opacity: 0.85;
}

.btn-primary {
  padding: 0.7rem 1.2rem;
  background: linear-gradient(180deg, #e0c35a, #8a6a12);
  color: #fffdf5;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
}

.btn-danger {
  padding: 0.35rem 0.7rem;
  background: linear-gradient(180deg, #e74c3c, #c0392b) !important;
  color: var(--white) !important;
  border: none;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(192, 57, 43, 0.2);
}

.btn-danger:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(192, 57, 43, 0.3);
}

.btn-sm {
  padding: 0.35rem 0.7rem;
  background: linear-gradient(180deg, #d4af37, #8a6a12);
  color: #fffdf5;
  border: none;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.data-table th,
.data-table td {
  padding: 0.7rem 0.6rem;
  border-bottom: 1px solid #e8eef5;
  text-align: right;
}

.data-table th {
  background: var(--blue-light);
  color: var(--navy);
  font-weight: 700;
}

.data-table tr:hover td {
  background: #fafcfe;
}

/* ---------- Login page ---------- */
body.page-login {
  overflow: hidden;
}

body.page-login .site-header,
body.page-login .site-footer {
  display: none !important;
}

.login-main {
  flex: 1;
  min-height: 100vh;
  min-height: 100dvh;
}

.login-page-bg {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at top, rgba(240, 208, 96, 0.45), transparent 55%),
    linear-gradient(165deg, #fffdf5 0%, #f5e6b0 48%, #e8cf6a 100%);
  padding: 1.25rem;
  padding: max(1.25rem, env(safe-area-inset-top)) max(1.25rem, env(safe-area-inset-right)) max(1.25rem, env(safe-area-inset-bottom)) max(1.25rem, env(safe-area-inset-left));
}

.login-box {
  background: #ffffff;
  padding: 2rem 1.75rem 1.75rem;
  border-radius: 22px;
  box-shadow: 0 18px 48px rgba(74, 55, 8, 0.16);
  border: 1px solid rgba(201, 162, 39, 0.35);
  width: 100%;
  max-width: 420px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.login-box::before {
  content: "";
  display: block;
  height: 4px;
  margin: -2rem -1.75rem 1.35rem;
  background: linear-gradient(90deg, #5c4508, #c9a227, #f0d060, #8a6a12);
}

.login-logo {
  width: 88px;
  height: 88px;
  margin: 0 auto 0.85rem;
  overflow: hidden;
}

.login-logo img {
  width: 88px !important;
  height: 88px !important;
  max-width: 88px;
  object-fit: contain;
  display: block;
  margin: 0 auto;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.14));
}

.login-header-text {
  margin-bottom: 1rem;
}

.login-header-text h1 {
  font-size: 1.15rem;
  color: var(--navy-dark);
  font-weight: 800;
  margin-bottom: 0.15rem;
  line-height: 1.4;
}

.login-header-text p {
  font-size: 0.92rem;
  color: var(--text-muted);
  font-weight: 600;
}

.login-title {
  color: var(--navy);
  font-size: 1.15rem;
  font-weight: 800;
  margin: 0 0 1.25rem;
  padding-top: 0.9rem;
  border-top: 1px solid rgba(212, 175, 55, 0.28);
}

.login-form .form-group {
  text-align: right;
  margin-bottom: 1.15rem;
}

.login-form label {
  display: block;
  font-weight: 700;
  color: var(--navy-dark);
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.login-input-wrap {
  width: 100%;
}

.login-form input {
  width: 100%;
  padding: 0.9rem 1rem;
  border: 1.5px solid rgba(201, 162, 39, 0.4);
  border-radius: 12px;
  background: #fffdf8;
  font-family: inherit;
  font-size: 1.05rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  text-align: center;
  color: var(--navy-dark);
  -webkit-appearance: none;
  appearance: none;
}

.login-form input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.22);
  background: #fff;
}

.btn-login {
  width: 100%;
  padding: 0.95rem 1rem;
  background: linear-gradient(180deg, #e0c35a, #c9a227 45%, #8a6a12);
  color: #fffdf5 !important;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s, filter 0.2s;
  box-shadow: 0 8px 18px rgba(138, 106, 18, 0.28);
  margin-top: 0.25rem;
  -webkit-appearance: none;
  appearance: none;
}

.btn-login:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(138, 106, 18, 0.38);
  filter: brightness(1.05);
}

.btn-login:active {
  transform: translateY(0);
}

.login-footer {
  margin-top: 1.25rem;
}

.login-footer a {
  color: var(--navy);
  font-weight: 700;
  font-size: 0.92rem;
  transition: color 0.2s;
}

.login-footer a:hover {
  color: var(--navy-dark);
}

.flash {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-weight: 600;
}

.flash.ok {
  background: #e8f8ef;
  color: #1e7e4a;
  border: 1px solid #b7e4c7;
}

.flash.err {
  background: #fdecea;
  color: #922b21;
  border: 1px solid #f5c6cb;
}

.admin-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.admin-top h1 {
  color: var(--navy);
  font-size: 1.35rem;
}

.table-wrap {
  overflow-x: auto;
}

.settings-checks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.65rem;
}

.settings-check {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.7rem 0.85rem;
  background: var(--gold-soft);
  border: 1px solid rgba(212, 175, 55, 0.35);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
}

.settings-check input {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--navy);
  cursor: pointer;
}

.settings-password-form {
  max-width: 720px;
}

.logo-preview-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  align-items: center;
}

.logo-preview {
  width: 120px;
  height: 120px;
  object-fit: contain;
  background: #fffdf5;
  border: 1px solid rgba(212, 175, 55, 0.4);
  border-radius: 10px;
  padding: 0.5rem;
}

.reports-actions-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.85rem;
  margin-bottom: 0.75rem;
}

.reports-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.reports-actions .btn-primary {
  font-size: 0.9rem;
  padding: 0.55rem 0.9rem;
}

.reports-filter {
  align-items: end;
}

.ltr-cell {
  direction: ltr;
  unicode-bidi: isolate;
  text-align: center;
}

.data-table input[type="checkbox"] {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--navy);
  cursor: pointer;
}

/* ---------- أدوات القائمة: حجم العرض وترقيم الصفحات ---------- */
.list-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.page-size {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
}

.page-size-btn {
  display: inline-block;
  min-width: 2.5rem;
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  border: 1px solid rgba(212, 175, 55, 0.55);
  background: var(--gold-soft);
  color: var(--navy-dark);
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  transition: background 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.page-size-btn:hover {
  background: var(--gold-mid);
  transform: translateY(-1px);
}

.page-size-btn.active {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  border-color: var(--navy-mid);
  color: var(--navy-dark);
  box-shadow: 0 2px 8px rgba(122, 92, 15, 0.28);
}

.list-range {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
}

.list-range strong {
  color: var(--navy-dark);
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 1rem;
}

.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.4rem;
  height: 2.4rem;
  padding: 0 0.7rem;
  border-radius: 10px;
  border: 1px solid rgba(212, 175, 55, 0.55);
  background: #fffdf5;
  color: var(--navy-dark);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.page-link:hover {
  background: var(--gold-soft);
  transform: translateY(-1px);
}

.page-link.active {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  border-color: var(--navy-mid);
  color: var(--navy-dark);
  box-shadow: 0 3px 10px rgba(122, 92, 15, 0.3);
}

.page-link.disabled {
  opacity: 0.45;
  pointer-events: none;
  cursor: default;
}

.page-dots {
  padding: 0 0.25rem;
  font-weight: 700;
  color: var(--text-muted);
}

/* ---------- حالة الشاشة (وضع الصيانة) ---------- */
.status-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.85rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
  border: 1px solid transparent;
}

.status-pill::before {
  content: "";
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: currentColor;
}

.status-on {
  background: #e8f8ef;
  color: #1e7e4a;
  border-color: #b7e4c7;
}

.status-off {
  background: #fdecea;
  color: #922b21;
  border-color: #f5c6cb;
}

.backup-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

/* ---------- Responsive ---------- */
.table-wrap {
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 1024px) {
  .admin-wrap {
    max-width: 100%;
    padding: 1.25rem 1rem;
  }

  .admin-top {
    align-items: flex-start;
  }

  .admin-top > div {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
  }
}

@media (max-width: 768px) {
  .header-inner {
    gap: 0.65rem;
  }

  .logo-seal {
    width: 72px;
    height: 72px;
  }

  .header-text h1 {
    font-size: 0.95rem;
    line-height: 1.4;
  }

  .header-text p {
    font-size: 0.78rem;
  }

  .site-main,
  body.page-inquiry .site-main {
    padding: 1rem 0.85rem 1.25rem;
  }

  .admin-form {
    grid-template-columns: 1fr 1fr;
  }

  .search-card-head {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-clarif {
    width: 100%;
    justify-content: center;
  }

  .import-form {
    flex-direction: column;
    align-items: stretch;
  }

  .import-form input[type="file"],
  .import-form .btn-primary {
    width: 100%;
  }

  .reports-actions,
  .reports-actions-bar,
  .import-preview-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .reports-actions .btn-primary,
  .import-preview-actions .btn-primary {
    width: 100%;
  }

  .login-box {
    padding: 1.5rem 1.15rem 1.35rem;
    max-width: 100%;
  }

  .login-box::before {
    margin: -1.5rem -1.15rem 1.15rem;
  }
}

@media (max-width: 560px) {
  html {
    font-size: 15px;
  }

  .logo-seal {
    width: 58px;
    height: 58px;
  }

  .header-text h1 {
    font-size: 0.82rem;
  }

  .header-text p {
    font-size: 0.72rem;
  }

  .page-title {
    font-size: 1.02rem;
  }

  .page-desc {
    font-size: 0.84rem;
  }

  .result-grid {
    grid-template-columns: 1fr;
  }

  .site-main {
    padding: 0.9rem 0.75rem 1.2rem;
  }

  .admin-form,
  .settings-password-form,
  .nationality-toggle {
    grid-template-columns: 1fr;
  }

  .admin-card,
  .search-card,
  .result-card {
    padding-left: 0.9rem;
    padding-right: 0.9rem;
    border-radius: 14px;
  }

  .admin-top h1 {
    font-size: 1.05rem;
  }

  .btn-sm,
  .btn-primary,
  .btn-search,
  .btn-login,
  .btn-outline {
    min-height: 44px;
  }

  .btn-search,
  .btn-login {
    font-size: 1rem;
  }

  button,
  input,
  select,
  textarea {
    font-size: 16px;
  }

  .data-table {
    font-size: 0.82rem;
  }

  .data-table th,
  .data-table td {
    padding: 0.55rem 0.4rem;
    white-space: nowrap;
  }

  .years-table-wrap,
  .table-wrap {
    margin-inline: -0.2rem;
  }

  .confirm-modal .modal-actions {
    flex-direction: column;
  }

  .info-banner {
    font-size: 0.84rem;
  }

  .num-step {
    width: 2.6rem;
    min-width: 2.6rem;
    min-height: 44px;
  }

  body.page-inquiry {
    height: auto;
    max-height: none;
    overflow: auto;
  }

  body.page-inquiry .site-main {
    overflow: visible;
    max-height: none;
  }

  body.page-inquiry .result-card {
    max-height: none;
    overflow: visible;
  }

  .site-footer {
    font-size: 0.75rem;
    padding: 0.75rem 0.85rem;
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
  }
}

@media (max-width: 380px) {
  .logo-seal {
    width: 48px;
    height: 48px;
  }

  .header-text h1 {
    font-size: 0.74rem;
  }

  .search-card-icon {
    width: 34px;
    height: 34px;
    min-width: 34px;
  }

  .login-logo,
  .login-logo img {
    width: 72px !important;
    height: 72px !important;
  }
}

@media (pointer: coarse) {
  .nat-option span,
  .settings-check,
  .btn-sm {
    min-height: 44px;
  }
}
