:root {
  --teal: #0f7c7a;
  --teal-dark: #0a5a59;
  --teal-soft: #d9eeed;
  --stats-bg: #eef7f6; /* gentle background for stats area */
  --stats-card-bg: linear-gradient(180deg, #eef7f6 0%, #f6fbfb 100%);
  --stats-text: #103233; /* dark-teal text for readability */
  --bg: #f5f7f7;
  --text: #113;
  --muted: #6b7b7b;
  --danger: #c0392b;
  --success: #2e7d32;
  --card: #ffffff;
  --shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
}

/* --- Multi-select dropdown (RTL-friendly) --- */
.multi-select-dropdown {
  position: relative;
  display: inline-block;
  .card-icon-img {
    width: 34px;
    height: 34px;
    object-fit: contain;
    display: block;
    filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.08));
  }

  /* For mosque icon we rely on the inline <img> so remove any CSS background and keep parent styling */
  .card-icon--mosque {
    background-image: none;
  }

  /* Ensure inline SVG inside card-icon is the correct size */
  .card-icon svg {
    width: 34px;
    height: 34px;
    display: block;
  }
  cursor: pointer;
  min-height: 44px;
  font-size: 15px;
  color: #0b0b0b;
}
.ms-btn:focus {
  outline: 2px solid rgba(0, 120, 212, 0.12);
}
.ms-btn::after {
  content: "▾";
  display: inline-block;
  transform: none;
  margin-left: 6px;
  color: var(--muted);
  font-size: 14px;
}
.ms-placeholder {
  color: var(--muted);
}
.ms-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.ms-tag {
  background: #eef7f6;
  color: #073;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.85rem;
}
.ms-count {
  background: #e6f0ff;
  color: #036;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.85rem;
}
.ms-panel {
  position: absolute;
  z-index: 60;
  right: 0;
  left: 0;
  margin-top: 8px;
  background: #fff;
  border: 1px solid #e6efef;
  border-radius: 8px;
  max-height: 220px;
  overflow: auto;
  box-shadow: 0 6px 18px rgba(20, 30, 40, 0.06);
}
.ms-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  cursor: pointer;
}
.ms-item:hover {
  background: #f7fdfc;
}
.ms-item input[type="checkbox"] {
  /* place checkbox visually to the right for RTL */
  order: 2;
  margin-left: 8px;
}
.ms-item span.label {
  order: 1;
  flex: 1;
  text-align: right;
}
.ms-item .check-mark {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  background: transparent;
  border: 1px solid #d6e7e5;
}
.ms-item input[type="checkbox"]:checked + .check-mark {
  background: #0ea58a;
  color: #fff;
  border-color: #0ea58a;
}
.ms-empty {
  padding: 10px;
  color: var(--muted);
  font-size: 0.95rem;
}

@media (min-width: 900px) {
  .ms-btn {
    min-height: 46px;
  }
}
* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  font-family: Tajawal, system-ui, -apple-system, Segoe UI, Roboto,
    "Noto Kufi Arabic", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.topbar {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 18px 16px;
  background: var(--teal-dark);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 1000;
}
.topbar-center {
  text-align: center;
}
.topbar .brand {
  color: #fff;
  text-decoration: none;
  font-weight: 800;
  font-size: 1.15rem;
}
.topbar .subtitle {
  font-size: 1rem;
  color: #cfeeed;
  margin-top: 2px;
}
.topbar-right {
  position: absolute;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.announcements {
  background: var(--teal);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
}
.stripe-label {
  background: rgba(0, 0, 0, 0.2);
  padding: 6px 10px;
  border-radius: 0 12px 12px 0;
  margin-inline-start: 8px;
}
.marquee {
  overflow: hidden;
  position: relative;
  flex: 1;
}
.marquee ul {
  display: flex;
  gap: 28px;
  list-style: none;
  padding: 0;
  margin: 0;
  white-space: nowrap;
  animation: scroll-rtl 30s linear infinite;
}
@keyframes scroll-rtl {
  0% {
    transform: translateX(-50%);
  }
  100% {
    transform: translateX(0);
  }
}
.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  padding: 24px;
  align-items: start;
}
.right-rail {
  position: sticky;
  top: 66px;
}
.logo-wrap {
  background: linear-gradient(180deg, var(--teal-dark), var(--teal));
  padding: 16px;
  border-radius: 16px;
  box-shadow: var(--shadow);
  height: 340px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.logo-wrap img {
  max-height: 260px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.3));
}
.sidebar {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.btn {
  display: block;
  text-align: center;
  padding: 12px 14px;
  background: var(--teal);
  color: #fff;
  border-radius: 12px;
  text-decoration: none;
  box-shadow: var(--shadow);
  border: none;
  cursor: pointer;
}
.btn:hover {
  background: var(--teal-dark);
}
.btn.small {
  padding: 6px 8px;
  border-radius: 8px;
}
.btn.primary {
  background: var(--teal-dark);
}
.btn.primary.disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.btn.danger {
  background: var(--danger);
}
/* Secondary (neutral) variant */
.btn.secondary {
  background: #e9f3f2;
  color: var(--teal-dark);
  box-shadow: none;
  border: 1px solid #d6eae9;
}
.btn.secondary:hover {
  background: #dff0ef;
}
.btn.danger:hover {
  filter: brightness(0.9);
}

/* Actions on cards: align buttons horizontally and space them */
.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  justify-content: flex-end;
}
.card-actions .btn {
  min-width: 90px;
}
.content {
  min-height: 60vh;
}
.flash-group {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}
.flash {
  padding: 10px 12px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  background: #fff;
}
.flash.success {
  border-right: 6px solid var(--success);
}
.flash.info {
  border-right: 6px solid var(--teal);
}
.flash.warning {
  border-right: 6px solid #d4a017;
}
.flash.danger {
  border-right: 6px solid var(--danger);
}
/* hide animation for success flashes */
.flash {
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.flash-hide {
  opacity: 0;
  transform: translateY(-8px);
}
.welcome-card {
  margin: 80px auto;
  background: var(--card);
  padding: 40px;
  border-radius: 18px;
  width: min(680px, 90%);
  text-align: center;
  box-shadow: var(--shadow);
  animation: pop 0.6s ease forwards;
}
.welcome-card h1 {
  margin: 0 0 10px 0;
  color: var(--teal-dark);
}
.welcome-card p {
  color: var(--muted);
  font-size: 1.1rem;
}
.section-title {
  margin: 10px 0 16px 0;
}
.card {
  background: var(--card);
  padding: 20px;
  border-radius: 16px;
  box-shadow: var(--shadow);
  position: relative; /* ensure absolute-positioned badges inside cards are anchored correctly */
}
.card.big {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 360px;
}

/* Office-specific card improvements */
.office-cards {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}
.office-cards .card {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 240px;
  padding: 16px 18px;
  border-radius: 12px;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.office-cards .card:hover {
  transform: translateY(-6px);
  box-shadow: 0 10px 30px rgba(2, 44, 44, 0.12);
}
.office-cards .card .card-icon {
  font-size: 34px;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #eaf7f5;
  border-radius: 10px;
}
/* Ensure icons inside the generic cards grid also get the same sizing and background */
.cards-grid .card .card-icon {
  font-size: 34px;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #eaf7f5;
  border-radius: 10px;
}
.office-cards .card h3 {
  margin: 0;
  color: var(--teal-dark);
  font-size: 1.05rem;
}
.office-cards .card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

/* Image inside card icon (use a small svg/png for consistent look) */
.card-icon-img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  display: block;
}

/* .card-icon--mosque styling kept minimal; inline SVG or <img> will render the icon */
.card-icon--mosque {
  background-image: none;
}

/* Modal map for picking location */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(4, 32, 32, 0.45);
  z-index: 1200;
}
.modal .modal-content {
  width: 92%;
  max-width: 1000px;
  background: #fff;
  padding: 12px;
  border-radius: 10px;
  box-shadow: 0 14px 40px rgba(2, 44, 44, 0.18);
  position: relative;
}
.modal-close {
  position: absolute;
  right: 10px;
  top: 6px;
  background: transparent;
  border: none;
  font-size: 22px;
  cursor: pointer;
}

/* Modal overlay/card used by mosque detail JS (centered, RTL-friendly) */
.modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 32, 32, 0.45);
  z-index: 1400;
  padding: 18px;
}
.modal-card {
  width: 100%;
  max-width: 720px;
  background: var(--card);
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(2, 44, 44, 0.18);
  padding: 20px 22px;
  direction: rtl;
  text-align: right;
  color: var(--teal-dark);
}

/* Utility: disable page scroll when modal/dialog is open */
.no-scroll,
html.no-scroll,
body.no-scroll {
  overflow: hidden !important;
  height: 100% !important;
}

/* Make the stats dialog itself non-scrollable; the inner .modal-card should handle scrolling */
dialog.stats-dialog {
  padding: 0 !important;
  border: none !important;
  overflow: hidden !important; /* prevent dialog from showing its own scrollbar */
}

dialog.stats-dialog .modal-card {
  overflow: auto !important; /* the single scrollbar should be here */
  -webkit-overflow-scrolling: touch;
}
.modal-card h3 {
  margin-top: 0;
  color: var(--teal-dark);
}
.modal-card p {
  margin: 6px 0;
  color: #333;
}
.modal-card strong {
  color: var(--teal-dark);
  margin-left: 6px;
}
.modal-card .btn {
  padding: 8px 12px;
  border-radius: 8px;
}

/* Form layout improvements for mosque form */
.form-card.full-width {
  max-width: 980px;
}
.form-card {
  max-width: 980px;
  margin: 18px auto;
  padding: 24px;
  box-shadow: 0 8px 30px rgba(2, 44, 44, 0.06);
  border-radius: 12px;
}
.form-card .form-row {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}
.form-card .form-row.full {
  grid-column: 1 / -1;
  grid-template-columns: 1fr;
}
.form-card .form-row label {
  text-align: right;
  font-weight: 600;
  color: var(--teal-dark);
  padding-right: 6px;
}
.form-card .form-row .input {
  display: block;
}
.form-card .form-row input[type="text"],
.form-card .form-row input[type="number"],
.form-card .form-row select,
.form-card .form-row input[type="hidden"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d6e0e0;
  border-radius: 8px;
  background: #fff;
}
.form-card .form-row input[readonly] {
  background: #fbfbfb;
  cursor: pointer;
}
.form-card .form-row .input input[type="checkbox"] {
  transform: scale(1.05);
  margin-left: 8px;
}
.form-card .form-row .small {
  font-size: 0.9rem;
  color: var(--muted);
}

/* Buttons */
.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
}
.form-actions .btn {
  padding: 10px 18px;
  border-radius: 10px;
}
.form-actions .btn.btn-secondary {
  background: #f0f5f6;
  color: var(--teal-dark);
}

@media (max-width: 900px) {
  .form-card {
    padding: 18px;
  }
  .form-card .form-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
  .form-card .form-row label {
    width: 100%;
    text-align: right;
    margin-bottom: 6px;
  }
  .form-actions {
    flex-direction: column-reverse;
  }
  .form-actions .btn {
    width: 100%;
  }
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 18px 18px;
}
.form-grid select,
.form-grid input[type="text"],
.form-grid input[type="date"],
.form-grid input[type="file"] {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #d6e0e0;
  border-radius: 10px;
  background: #fbfdfd;
  font-size: 15px;
  color: #0b0b0b;
}
.actions-end {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 10px;
}
.table {
  width: 100%;
  border-collapse: collapse;
}
.table th,
.table td {
  border-bottom: 1px solid #eef2f2;
  padding: 10px;
  text-align: right;
}
.table-wrap {
  overflow: auto;
}
.table.selectable tbody tr:hover {
  background: #f8fbfb;
}
.table.selectable td:first-child {
  text-align: center;
}
.badge {
  padding: 4px 8px;
  border-radius: 8px;
  color: #fff;
  font-size: 0.8rem;
}
.badge.success {
  background: var(--success);
}
.badge.danger {
  background: var(--danger);
}
.admin-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 260px));
  gap: 20px;
  place-content: center;
  margin: 24px auto 12px;
}
.admin-card {
  position: relative;
  background: var(--card);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  border: 1px solid #e9f1f1;
  transition: transform 0.15s ease, box-shadow 0.15s ease,
    border-color 0.2s ease;
  min-height: 160px;
}
.admin-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.1);
  border-color: #dbe7e7;
}
.admin-card-icon {
  font-size: 44px;
  line-height: 1;
}
.admin-card-title {
  font-weight: 800;
  color: var(--teal-dark);
  font-size: 1.2rem;
}
.soon-badge {
  position: absolute;
  left: 14px;
  top: 14px;
  background: #ffd166;
  color: #4b3f00;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.9rem;
  box-shadow: var(--shadow);
}
.counter-badge {
  background: #0f7c7a;
  color: #fff;
  padding: 4px 10px;
  border-radius: 999px;
  box-shadow: var(--shadow);
}
.soon {
  text-align: center;
  animation: pulse 2s infinite ease-in-out;
}
.soon.pulse {
  animation: pulse 1.4s infinite ease-in-out;
}
@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.03);
  }
}
@keyframes pop {
  0% {
    transform: scale(0.96);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}
.login-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  background: linear-gradient(180deg, #f1f8f8, #e7f2f2);
}
.login-card {
  background: #fff;
  width: min(420px, 92%);
  padding: 26px;
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.login-card h2 {
  margin-top: 0;
}
.notif-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.notif-list li {
  padding: 12px 10px;
  border-bottom: 1px solid #eef2f2;
}
.notif-list li.unread {
  background: #f0fbfa;
}
.bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  text-decoration: none;
  color: #fff;
}
.bell-badge {
  position: absolute;
  top: -6px;
  left: -6px;
  background: #ff5252;
  color: #fff;
  border-radius: 10px;
  padding: 0 6px;
  font-size: 0.75rem;
}
.user-name {
  white-space: nowrap;
}

/* Store card counter at top-left */
.store-card {
  position: relative;
}
.counter-abs {
  position: absolute;
  top: 10px;
  left: 10px;
}

/* Toolbar layout and search */
.store-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.store-toolbar .left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.search {
  padding: 8px 10px;
  border: 1px solid #dde6e6;
  border-radius: 10px;
  min-width: 220px;
}

/* Search input used in section outgoing stores */
.search-input {
  flex: 1;
  padding: 12px 16px;
  border-radius: 999px;
  border: 1px solid rgba(15, 124, 122, 0.12);
  box-shadow: 0 10px 30px rgba(15, 124, 122, 0.06); /* subtle teal shadow */
  outline: none;
  background: #fff;
  font-size: 15px;
}
.search-input:focus {
  box-shadow: 0 14px 36px rgba(15, 124, 122, 0.1);
  border-color: rgba(15, 124, 122, 0.22);
}

/* Clear button style: use site success/green */
.btn-clear {
  background: var(--success);
  color: #fff;
  border-radius: 10px;
  padding: 8px 12px;
  border: none;
}
.btn-clear:hover {
  background: #27692a;
}

/* Paperclip link & files list */
a.clip {
  text-decoration: none;
  font-size: 1.1rem;
}
a.clip:hover {
  text-decoration: underline;
}
.files-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.files-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #eef2f2;
}
.file-ico {
  font-size: 1.1rem;
}

/* Admin inline add/delete controls */
.inline-ops {
  display: inline-flex;
  gap: 6px;
  margin-inline-start: 8px;
  vertical-align: middle;
}
.chip {
  background: #eaf5f4;
  border: 1px solid #d6eeec;
  border-radius: 999px;
  padding: 2px 8px;
  cursor: pointer;
}
.chip:hover {
  background: #dff1ef;
}
.inline-add {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}
.inline-add.fixed-bottom {
  position: fixed;
  inset-inline: 0;
  bottom: 24px;
  margin: auto;
  width: min(520px, 92%);
  background: #fff;
  border: 1px solid #e6eeee;
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 10px;
  z-index: 1200;
}
.inline-add input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #dde6e6;
  border-radius: 10px;
}

/* Priority badges */
.prio {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  color: #fff;
  font-size: 0.85rem;
  box-shadow: var(--shadow);
}
.prio-urgent {
  background: #d32f2f;
} /* red */
.prio-medium {
  background: #f39c12;
} /* orange */
.prio-normal {
  background: #2e7d32;
} /* green */

/* Maintenance three cards */
.maint-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 20px;
  margin-top: 10px;
}
.maint-card {
  position: relative;
  background: #fff;
  border: 1px solid #e6eeee;
  border-radius: 18px;
  padding: 26px 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease,
    border-color 0.2s ease;
  min-height: 160px;
}
.maint-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.1);
  border-color: #dbe7e7;
}
.maint-card .icon {
  font-size: 46px;
}
.maint-card .title {
  font-weight: 800;
  color: var(--teal-dark);
  font-size: 1.15rem;
}
.maint-card.inbox .icon {
  filter: drop-shadow(0 2px 6px rgba(15, 124, 122, 0.25));
}
.maint-card.pending .icon {
  filter: drop-shadow(0 2px 6px rgba(243, 156, 18, 0.25));
}
.maint-card.done .icon {
  filter: drop-shadow(0 2px 6px rgba(46, 125, 50, 0.25));
}
.maint-card .counter-badge {
  position: absolute;
  top: 12px;
  left: 12px;
}

/* New outgoing card: visually consistent with other maint cards but without a counter */
.maint-card.new-outgoing .icon {
  font-size: 44px;
}
.maint-card.new-outgoing .counter-badge {
  display: none;
}

.tbl th,
.tbl td {
  padding: 0.65rem 0.8rem;
  vertical-align: middle;
}
.tbl th {
  white-space: nowrap;
}
.tbl td.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Users Admin styles */
.page.users-admin .grid.two {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 1rem;
}
.card {
  background: #fff;
  border-radius: 16px;
  padding: 1rem;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.08);
}
.card-header {
  font-weight: 700;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid #eee;
  padding-bottom: 0.5rem;
}
.form .row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 0.5rem;
  align-items: center;
  margin: 0.4rem 0;
}
.form input,
.form select {
  padding: 0.65rem 0.85rem;
  border: 1px solid #ddd;
  border-radius: 12px;
  outline: none;
  font-size: 15px;
  color: #0b0b0b;
}

/* increase vertical spacing between label and field and between rows */
.form-grid > .grid-3 > div {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 8px;
}
.form-grid label {
  font-size: 15px;
  font-weight: 600;
  color: #071018;
  margin-bottom: 4px;
}
.table table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.table thead th {
  background: #f7f7fb;
  text-align: right;
  padding: 0.6rem 0.8rem;
  position: sticky;
  top: 0;
}
.table tbody td {
  padding: 0.55rem 0.8rem;
  border-bottom: 1px solid #f0f0f0;
}
/* center department column cells */
.table td.dept-cell {
  text-align: center;
  vertical-align: middle;
}

/* faint vertical separators between columns for improved readability */
.table td,
.table th {
  border-right: 1px solid rgba(0, 0, 0, 0.03);
}
.table tr td:last-child,
.table tr th:last-child {
  border-right: none;
}
.badge {
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.85em;
}
.badge.ok {
  background: #eaf9f0;
  color: #0a7a3f;
}
.badge.muted {
  background: #f3f3f3;
  color: #666;
}
.actions .btn.sm {
  padding: 0.25rem 0.5rem;
  border-radius: 10px;
  margin-inline-start: 0.2rem;
}
dialog::backdrop {
  background: rgba(0, 0, 0, 0.2);
}

/* --- Emergency: ensure card icons are always visible --- */
/* Added to force icons to render if other rules hide or size them to 0 */
.card-icon svg,
.card-icon img {
  display: block !important;
  width: 34px !important;
  height: 34px !important;
  max-width: 100% !important;
}
.card-icon {
  background: #eaf7f5 !important;
  align-items: center !important;
  justify-content: center !important;
}

/* Requests card badge (top-left) */
.card-badge {
  position: absolute;
  left: 12px;
  top: -10px;
  background: var(--teal);
  color: #fff;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(2, 44, 44, 0.12);
}

/* Requests table & statuses */
.requests-table {
  width: 100%;
  border-collapse: collapse;
}
.requests-table th,
.requests-table td {
  padding: 10px 12px;
  text-align: right;
  border-bottom: 1px solid #eef3f3;
}
.requests-table thead th {
  background: #fbfbfb;
  font-weight: 700;
  color: var(--teal-dark);
}
.status {
  padding: 6px 10px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.95rem;
}
.status-pending {
  background: #fff8e6;
  color: #b36b00;
  border: 1px solid #ffeccf;
}
.status-accepted {
  background: #e8f8ef;
  color: #157a3b;
  border: 1px solid #dff2e6;
}
.status-rejected {
  background: #fdecea;
  color: #b8332a;
  border: 1px solid #fbd7d7;
}

.actions-cell {
  display: flex;
  gap: 8px;
  justify-content: flex-start;
}
.btn.small {
  padding: 6px 10px;
  border-radius: 8px;
}
.btn.primary.small {
  background: var(--teal-dark);
  color: #fff;
}
.btn.btn-secondary {
  background: #f3f6f6;
  color: var(--teal-dark);
  border: 1px solid #e3ecec;
}

/* Modal preview tweaks */
.modal {
  display: none;
}
.modal .modal-content {
  direction: rtl;
  max-width: 800px;
}
.modal .modal-content table td {
  border: none;
  padding: 8px 6px;
}

.modal {
  min-width: 380px;
}
.btn.primary {
  background: #2f80ed;
  color: #fff;
}
/* Hide native dialog chrome */
dialog {
  border: none;
  border-radius: 16px;
  padding: 0;
}
dialog .modal {
  padding: 1rem 1.2rem;
}

.toolbar .search-wrap input {
  max-width: 420px;
}

.actions.spaced {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
}

.maint-card.stats {
  background: #fff;
  border: 1px solid #e7efef;
}

/* Reports card accent */
.maint-card.reports {
  background: #fff;
  border: 1px solid rgba(14, 160, 140, 0.06);
}
.maint-card.reports .icon {
  color: var(--teal-dark);
  filter: drop-shadow(0 6px 18px rgba(15, 124, 122, 0.12));
}
.maint-card.reports .badge-soft {
  background: rgba(15, 124, 122, 0.08);
  color: var(--teal-dark);
  padding: 6px 10px;
  border-radius: 10px;
}

/* ===== Enhanced Maintenance Stats Dialog (visual-only) ===== */
.stats-dialog {
  padding: 0;
  border: 0;
}
.stats-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
}
.stats-dialog .modal {
  width: min(1100px, 96vw);
  max-height: 88vh;
  overflow: auto;
  background: #ffffff; /* outer card stays white */
  border-radius: 20px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.18);
  padding: 18px 20px 22px;
  margin: 0 auto;
  animation: pop 0.22s ease;
}
.stats-dialog .toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: #ffffff;
  padding: 6px 0 10px;
  z-index: 2;
}
.stats-dialog .toolbar h3 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--teal-dark);
  letter-spacing: 0.2px;
}
.stats-dialog .btn.small {
  padding: 8px 14px;
  border-radius: 12px;
  border: 1px solid #e8eeee;
  background: #f8fbfb;
  cursor: pointer;
}
.stats-dialog .btn.small:hover {
  background: #f1f6f6;
}

/* Grid layout */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 14px;
  margin-top: 6px;
}

/* KPI tiles row */
.kpis {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.kpi {
  /* lighter, eye-friendly KPI tiles */
  background: var(--stats-card-bg);
  color: var(--stats-text);
  border-radius: 14px;
  padding: 14px 14px 12px;
  box-shadow: 0 8px 20px rgba(16, 38, 36, 0.06);
  border: 1px solid rgba(18, 50, 50, 0.06);
  text-align: center;
}
.kpi .kpi-val {
  font-size: 1.85rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 6px;
  color: var(--teal-dark);
}
.kpi .kpi-label {
  font-size: 0.95rem;
  color: var(--muted);
}

/* top summary small KPI boxes */
.maint-summary {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 6px;
}
.kpi-box {
  background: var(--card);
  padding: 8px 10px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  min-width: 96px;
  max-width: 150px;
  text-align: center;
  flex: 0 0 auto;
}
.kpi-box .kpi-val {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--teal-dark);
  line-height: 1;
}
.kpi-box .kpi-label {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 4px;
}

/* ensure the summary stays on one row on larger screens and scrolls on very narrow screens */
@media (min-width: 900px) {
  .maint-summary {
    overflow-x: visible;
  }
}

/* special colors by metric without changing markup */
#kpi-pending.kpi-val,
#kpi-pending {
  color: var(--danger);
} /* red for غير منجزة */
#kpi-missing.kpi-val,
#kpi-missing {
  color: #f39c12;
} /* orange for نواقص المستندات */
#kpi-done.kpi-val,
#kpi-done {
  color: var(--success);
} /* green for منجزة */
#kpi-total.kpi-val,
#kpi-total {
  color: var(--teal-dark);
} /* teal for إجمالي */

.chart {
  /* friendly, mid-tone chart cards */
  background: var(--stats-card-bg);
  color: var(--stats-text);
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 8px 20px rgba(16, 38, 36, 0.06);
  border: 1px solid rgba(18, 50, 50, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  position: relative;
}
.chart .chart-title {
  position: absolute;
  top: 12px;
  right: 16px;
  font-weight: 700;
  color: var(--teal-dark);
  background: rgba(15, 124, 122, 0.09);
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 0.95rem;
}

/* center classification names column styling */
#class-names {
  display: flex;
  flex-direction: column;
  gap: 6px;
  direction: rtl;
}
.class-name-row {
  padding: 6px 8px;
  text-align: right;
  font-size: 14px;
  font-weight: 600;
  color: #0b1816;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  direction: rtl;
  unicode-bidi: plaintext;
}
.chart.hbar {
  grid-column: span 6;
}
.chart.donut {
  grid-column: 1 / -1;
  min-height: 260px;
  justify-self: center;
}
.chart.line {
  grid-column: span 6;
}
.chart.stacked {
  grid-column: span 6;
}
.chart-caption {
  /* subtitle under charts */
  margin-top: 8px;
  font-weight: 700;
  color: var(--stats-text);
  text-align: center;
}
.chart-canvas {
  width: 100%;
  height: 100%;
}
.list ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.list ul li {
  padding: 6px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.03);
}
.chart.hbar .chart-canvas {
  padding-top: 6px;
}
/* hbar names column: ensure text is right-aligned, clipped with ellipsis, and has enough width */
.hbar-names {
  padding-right: 6px;
  padding-left: 6px;
}
.hbar-names div {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* when numeric label is outside bar, make sure it stands out */
.chart svg text {
  font-weight: 700;
}

/* New: hbar list rows with circular count badges */
.hbar-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.hbar-list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 6px;
}
.hbar-badge {
  min-width: 44px;
  height: 44px;
  border-radius: 999px;
  background: var(--teal);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
  padding: 0 10px;
}
.hbar-badge.small {
  min-width: 36px;
  height: 36px;
  font-size: 13px;
}
.hbar-list-row:hover .hbar-badge {
  transform: translateY(-1px);
}

/* enforce visual order: badge on left, name on right */
.hbar-list-row > div:first-child {
  order: 1;
}
.hbar-list-row > div:last-child {
  order: 2;
}

/* percent badges for employees */
.percent-badge {
  min-width: 44px;
  height: 44px;
  border-radius: 999px;
  background: #2f7f7d;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
  padding: 0 8px;
}
.percent-badge.pct-high {
  background: var(--success);
}
.percent-badge.pct-mid {
  background: #f39c12;
}
.percent-badge.pct-low {
  background: #c0392b;
}
.chart-caption.small {
  font-size: 0.95rem;
  margin-top: 4px;
}
/* Lists card */
.lists {
  grid-column: 1 / -1;
  background: var(--stats-card-bg);
  color: var(--stats-text);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 8px 20px rgba(16, 38, 36, 0.06);
  border: 1px solid rgba(18, 50, 50, 0.06);
}
.lists .list {
  margin: 0;
  padding: 0;
}
.lists .list + .list {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
}

/* Responsive adjustments */
@media (max-width: 980px) {
  .chart.hbar,
  .chart.donut,
  .chart.line,
  .chart.stacked {
    grid-column: 1 / -1;
  }
  .kpis {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 560px) {
  .kpis {
    grid-template-columns: 1fr;
  }
}
/* ===== End Enhanced Styles ===== */

.chart svg text {
  fill: var(--stats-text);
}
.chart .axis text {
  fill: var(--stats-text);
}

/* Close button color = title color */
.stats-dialog .toolbar #closeStats {
  color: var(--teal-dark);
  border-color: var(--teal-dark);
  background: transparent;
}
.stats-dialog .toolbar #closeStats:hover {
  background: rgba(15, 124, 122, 0.08);
}

/* --- Added: make table scroll inside its card, keep page stable --- */
.card.table-wrap {
  position: relative;
  /* keep card layout stable; table will scroll inside */
}
.card.table-wrap .table-scroll {
  max-height: 520px; /* adjust as needed */
  overflow: auto; /* both vertical and horizontal */
  padding-right: 0.25rem;
}

/* Improved table presentation for wide tables inside cards (e.g. معاملات منجزة) */
.card.table-wrap {
  overflow: auto; /* allow internal scrolling when table is wider than card */
  -webkit-overflow-scrolling: touch;
  padding: 6px; /* small inner gap so scrollbars don't touch edges */
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.6),
    rgba(250, 250, 250, 0.4)
  );
  border-radius: 12px;
}

/* Make the inner table size to content but allow it to shrink to container width */
.card.table-wrap .tbl {
  width: max-content; /* let columns size to their content */
  min-width: 100%; /* but at least fill the card so columns align nicely */
  border-collapse: separate;
}

/* Center all values in the done table for better visual balance */
.card.table-wrap .tbl th,
.card.table-wrap .tbl td {
  text-align: center !important;
  vertical-align: middle !important;
  padding: 0.65rem 0.9rem;
  white-space: normal; /* allow wrapping where needed */
}

/* (incoming form visual polish was reverted to restore original sizing) */

/* Keep monospace font but center its cells */
.card.table-wrap .tbl td.mono {
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Sticky header with subtle shadow to separate from scrolling body */
.card.table-wrap .tbl thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fbfdff;
  box-shadow: 0 6px 12px rgba(10, 20, 20, 0.03);
}

/* Zebra rows and hover */
.card.table-wrap .tbl tbody tr:nth-child(odd) {
  background: #ffffff;
}
.card.table-wrap .tbl tbody tr:nth-child(even) {
  background: #fbfdfe;
}
.card.table-wrap .tbl tbody tr:hover {
  background: #f4fbff;
}

/* Make the paperclip & action column smaller while keeping centered */
.card.table-wrap .tbl td:first-child {
  width: 36px;
}
.card.table-wrap .tbl td:last-child {
  min-width: 120px;
}

/* Thin, comfortable scrollbars */
.card.table-wrap::-webkit-scrollbar {
  height: 10px;
}
.card.table-wrap::-webkit-scrollbar-thumb {
  background: rgba(15, 124, 122, 0.18);
  border-radius: 999px;
}
.card.table-wrap {
  scrollbar-width: thin;
  scrollbar-color: rgba(15, 124, 122, 0.18) transparent;
}

/* Ensure table header text wraps nicely on narrow screens */
.card.table-wrap .tbl thead th {
  white-space: normal;
}

/* Pagination controls */
.card .card-pagination {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  align-items: center;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}
.card .card-pagination .page-btn {
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  border: 1px solid #ccc;
  background: #fff;
  cursor: pointer;
}
.card .card-pagination .page-btn.active {
  background: #007bff;
  color: #fff;
  border-color: #007bff;
}

/* Widen notes column default (can be targeted by JS if header matches) */
.tbl th.notes,
.tbl td.notes {
  min-width: 320px;
  max-width: 600px;
  white-space: normal;
  word-break: break-word;
}

/* Global back button (RTL-friendly) */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: linear-gradient(90deg, var(--teal) 0%, var(--teal-dark) 100%);
  color: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow);
  text-decoration: none;
  font-weight: 700;
  margin-bottom: 12px;
}
.back-btn .ico {
  font-size: 18px;
  transform: rotate(180deg); /* show a left arrow visually for RTL */
}
.back-btn.small {
  padding: 6px 10px;
  border-radius: 10px;
}
.back-btn.hidden {
  display: none;
}
