@charset "utf-8";

:root {
  
  --color-navy: #14163d;
  --color-navy-soft: #3d4173;

  --color-ink: #14163d;
  --color-ink-soft: #3d4173;
  --color-accent: #ed1c24;
  --color-accent-hover: #c8161e;
  --color-accent-soft: #fbe2e3;

  --color-info: #1c75bc;
  --color-info-hover: #155d94;
  --color-info-soft: #e2eef8;

  --color-bg: #f4f3ef;
  --color-bg-alt: #faf9f5;
  --color-surface: #ffffff;

  --color-border: rgba(20, 22, 61, 0.12);
  --color-border-strong: rgba(20, 22, 61, 0.22);

  --color-success: #1f8a4c;
  --color-success-soft: #e6f4ec;
  --color-warning: #b8791b;
  --color-warning-soft: #faf0dd;
  --color-danger: var(--color-accent);
  --color-danger-soft: var(--color-accent-soft);
  --color-muted: #6b7280;

  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  --shadow-subtle: 0 1px 2px rgba(20, 22, 61, 0.05), 0 1px 1px rgba(20, 22, 61, 0.04);
  --shadow-lift: 0 4px 16px rgba(20, 22, 61, 0.08);

  --font-family: 'Segoe UI', Tahoma, 'Cairo', Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-ink);
  font-family: var(--font-family);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}
a:hover,
a:focus {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font-family: inherit;
}

h1,
h2,
h3,
h4 {
  margin: 0 0 var(--space-3);
  font-weight: 700;
  color: var(--color-ink);
}

p {
  margin: 0 0 var(--space-3);
}

/* ---- App shell / top nav ---- */

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.top-nav {
  flex-shrink: 0;
  height: 56px;
  background: var(--color-navy);
  color: #fff;
  display: flex;
  align-items: center;
  gap: var(--space-5);
  padding: 0 var(--space-4);
}

.top-nav-logo {
  display: block;
  height: 28px;
  width: auto;
  flex-shrink: 0;
}

.top-nav-brand {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.top-nav-burger {
  display: none;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius-sm);
  background: transparent;
  color: #fff;
  font-size: 1.05rem;
  cursor: pointer;
}
.top-nav-burger:hover {
  background: rgba(255, 255, 255, 0.1);
}

.top-nav-sections {
  flex: 1;
  display: flex;
  align-items: stretch;
  gap: var(--space-1);
  height: 100%;
  min-width: 0;
  /* NO overflow here. An earlier version set overflow-x:auto/overflow-y:hidden
     to let nine section labels scroll on a narrow screen — but that turns this
     56px-tall row into a clipping box, and every dropdown starts at top:100%,
     i.e. exactly at its bottom edge, so all of them were clipped away
     entirely. The labels shrink at 1024px instead (see the media query
     below), and the row is allowed to squeeze rather than scroll. */
  flex-wrap: nowrap;
}

.top-nav-section {
  position: relative;
  display: flex;
  align-items: center;
}

.top-nav-label {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  height: 100%;
  padding: 0 var(--space-3);
  background: none;
  border: none;
  color: rgba(244, 243, 239, 0.75);
  font-size: 0.86rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.top-nav-label:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}

.top-nav-label.active {
  color: #fff;
  box-shadow: inset 0 -3px var(--color-accent);
}

.top-nav-label.open {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
}

.top-nav-chevron {
  display: inline-block;
  font-size: 0.7rem;
  transition: transform 0.15s;
}

.top-nav-label.open .top-nav-chevron,
.top-nav-user-btn.open .top-nav-chevron {
  transform: rotate(180deg);
}

.top-nav-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 20;
  list-style: none;
  margin: 0;
  padding: var(--space-2);
  min-width: 210px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lift);
  max-height: calc(100vh - 56px - var(--space-3));
  overflow-y: auto;
  overscroll-behavior: contain;
  display: none;
}

.top-nav-section.open > .top-nav-dropdown {
  display: block;
}

.top-nav-section:hover > .top-nav-dropdown {
  display: block;
}

.top-nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--color-ink);
  font-size: 0.86rem;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.top-nav-link:hover {
  background: var(--color-bg);
  color: var(--color-ink);
}

.top-nav-link.active {
  background: var(--color-accent);
  color: #fff;
}
.top-nav-link.active:hover {
  background: var(--color-accent-hover);
  color: #fff;
}

.top-nav-dropdown-group {
  position: relative;
}

.top-nav-dropdown-group-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  width: 100%;
  background: none;
  border: none;
  font-family: inherit;
  cursor: pointer;
  text-align: right;
}

.top-nav-dropdown-group-label .top-nav-chevron {
  font-size: 0.7rem;
  color: var(--color-muted);
  transform: rotate(90deg);   /* points toward the flyout side when closed */
  transition: transform 0.15s;
}

.top-nav-dropdown-group.is-open > .top-nav-dropdown-group-label .top-nav-chevron {
  transform: rotate(270deg);
}
.top-nav-dropdown-group.is-open > .top-nav-dropdown-group-label {
  background: var(--color-bg);
  color: var(--color-ink);
}

.top-nav-dropdown-subgroup {
  position: fixed;
  z-index: 40;
  display: none;
  margin: 0;
  padding: var(--space-2);
  min-width: 210px;
  max-height: calc(100vh - var(--space-3));
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lift);
}

.top-nav-dropdown-group.is-open > .top-nav-dropdown-subgroup {
  display: block;
}

/* noursina addition: the user menu keeps a small identity header, and the
   pending-members alert that this panel already had. */
.top-nav-dropdown-head {
  padding: var(--space-2) var(--space-3) var(--space-3);
  margin-bottom: var(--space-2);
  border-bottom: 1px solid var(--color-border);
}
.top-nav-dropdown-head strong {
  display: block;
  font-size: 0.88rem;
  color: var(--color-ink);
}
.top-nav-dropdown-head span {
  font-size: 0.76rem;
  color: var(--color-muted);
}

.top-nav-user {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 0.82rem;
  color: rgba(244, 243, 239, 0.75);
}

.top-nav-user .btn {
  border-color: rgba(244, 243, 239, 0.3);
  color: #fff;
}

.top-nav-user .btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.top-nav-user-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: none;
  border: none;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  color: rgba(244, 243, 239, 0.85);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.top-nav-user-btn:hover,
.top-nav-user-btn.open {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
}

.top-nav-alert {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-1);
  color: rgba(244, 243, 239, 0.8);
  font-size: 0.9rem;
}
.top-nav-alert:hover {
  color: #fff;
}

/* ---- Global search ---- */

.global-search {
  position: relative;
  flex-shrink: 1;
  min-width: 0;
  width: 240px;
  margin: 0;
}

@media (max-width: 1024px) {
  .top-nav-user-name {
    display: none;
  }

  .global-search {
    width: 150px;
  }

  .top-nav-label {
    padding: 0 var(--space-2);
    font-size: 0.8rem;
  }
}

@media (max-width: 480px) {
  .global-search {
    width: 110px;
  }
}

.global-search-icon {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  color: rgba(244, 243, 239, 0.55);
  display: flex;
  pointer-events: none;
}

.global-search-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 0.82rem;
  padding: 7px 34px 7px var(--space-3);
}

.global-search-input::placeholder {
  color: rgba(244, 243, 239, 0.55);
}

.global-search-input:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.35);
}

.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-y: auto;
}

.page-content {
  padding: var(--space-6);
  flex: 1;
  min-width: 0;
}

/* ---- Back link ---- */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--color-muted);
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: var(--space-4);
}

.back-link:hover {
  color: var(--color-accent);
}

/* ---- Tabs ---- */

.tabs {
  display: flex;
  gap: var(--space-2);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-5);
}

.tab-btn {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  color: var(--color-muted);
  font-weight: 600;
  font-size: 0.94rem;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  cursor: pointer;
  margin-bottom: -1px;
}

.tab-btn:hover {
  color: var(--color-ink);
}

.tab-btn.active {
  color: var(--color-accent);
  border-color: var(--color-accent);
}

/* ---- Cards / surfaces ---- */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-subtle);
}

.card + .card {
  margin-top: var(--space-4);
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: var(--space-4);
}

/* ---- Buttons ---- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.55;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
  white-space: nowrap;
  text-shadow: none;
  box-shadow: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled),
.btn-primary:focus,
.btn-primary:active,
.btn-primary.active {
  background: var(--color-accent-hover);
  border-color: var(--color-accent-hover);
  color: #fff;
}

.btn-secondary {
  background: transparent;
  border-color: var(--color-border-strong);
  color: var(--color-ink);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-bg-alt);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--color-muted);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--color-ink);
  background: transparent;
}

.btn-danger {
  background: transparent;
  border-color: var(--color-danger);
  color: var(--color-danger);
}

.btn-danger:hover:not(:disabled),
.btn-danger:focus,
.btn-danger:active {
  background: var(--color-danger-soft);
  border-color: var(--color-danger);
  color: var(--color-danger);
}

.btn-sm {
  padding: var(--space-1) var(--space-3);
  font-size: 0.8rem;
}

/* ---- Forms ---- */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-bottom: var(--space-4);
}

.field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-ink-soft);
  margin: 0;
}

.field-hint {
  font-size: 0.78rem;
  color: var(--color-muted);
}

.field-error {
  font-size: 0.78rem;
  color: var(--color-danger);
}

.input {
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  font-size: 0.92rem;
  background: var(--color-surface);
  color: var(--color-ink);
  width: 100%;
}

.input:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
  border-color: var(--color-accent);
}

textarea.input {
  resize: vertical;
  min-height: 80px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0 var(--space-4);
}

@media (max-width: 780px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

.responsive-grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  align-items: start;
}

.responsive-grid-main-side {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: var(--space-4);
  align-items: start;
}

@media (max-width: 900px) {
  .responsive-grid-2col,
  .responsive-grid-main-side {
    grid-template-columns: 1fr;
  }
}

/* ---- Tables ---- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.89rem;
}

table.data-table th {
  text-align: right;
  padding: var(--space-3) var(--space-4);
  background: var(--color-bg-alt);
  font-weight: 700;
  color: var(--color-ink-soft);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

table.data-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

table.data-table tbody tr:hover {
  background: var(--color-bg-alt);
}

table.data-table tbody tr:last-child td {
  border-bottom: none;
}

table.data-table tbody tr.clickable {
  cursor: pointer;
}

/* ---- Badges ---- */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px var(--space-2);
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  /* neutralises Bootstrap 3's own grey .badge before a variant paints it */
  background: var(--color-border);
  color: var(--color-muted);
  line-height: 1.55;
  min-width: 0;
  text-shadow: none;
}

.badge-success {
  background: var(--color-success-soft);
  color: var(--color-success);
}

.badge-warning {
  background: var(--color-warning-soft);
  color: var(--color-warning);
}

.badge-danger {
  background: var(--color-danger-soft);
  color: var(--color-danger);
}

.badge-muted {
  background: var(--color-border);
  color: var(--color-muted);
}

.badge-accent {
  background: var(--color-accent-soft);
  color: var(--color-accent);
}

.badge-info {
  background: var(--color-info-soft);
  color: var(--color-info);
}

/* ---- Stat tiles ---- */

.stat-tiles {
  display: grid;
  /* 210px, not 180px: at 180 a 1440px screen fits seven per row, so the
     eighth tile sat alone on a second row beside a long empty gap. */
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.stat-tile {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
}

a.stat-tile {
  display: block;
  width: 100%;
  text-align: inherit;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.stat-tile-value {
  font-size: 1.7rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--color-ink);
}

.stat-tile-label {
  font-size: 0.82rem;
  color: var(--color-muted);
  margin-top: var(--space-1);
}

/* -- coloured variants --
   Each tile/card carries one identity colour: a tinted surface, a solid edge
   and a coloured figure, so the dashboard reads at a glance instead of being
   a wall of white. Every colour and tint below is a brand token (the navy
   tint is the navy token at 6% — no new hex is introduced). */
.tile-navy    { --tile: var(--color-navy);    --tile-soft: rgba(20, 22, 61, 0.09); }
.tile-accent  { --tile: var(--color-accent);  --tile-soft: var(--color-accent-soft); }
.tile-info    { --tile: var(--color-info);    --tile-soft: var(--color-info-soft); }
.tile-success { --tile: var(--color-success); --tile-soft: var(--color-success-soft); }
.tile-warning { --tile: var(--color-warning); --tile-soft: var(--color-warning-soft); }

.stat-tile[class*="tile-"] {
  background: var(--tile-soft);
  border-color: transparent;
  /* explicit border-right, not border-inline-start: this panel is always
     dir="rtl", and an explicit side leaves no doubt that the colour bar sits
     on the edge the eye starts from. */
  border-right: 5px solid var(--tile);
  transition: transform 0.15s, box-shadow 0.15s;
}

.stat-tile[class*="tile-"] .stat-tile-value {
  font-size: 1.85rem;
}

a.stat-tile[class*="tile-"]:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lift);
}

.stat-tile[class*="tile-"] .stat-tile-value {
  color: var(--tile);
}

.stat-tile[class*="tile-"] .stat-tile-label {
  color: var(--color-ink-soft);
}

/* Analytics cards: a coloured top edge and a coloured section title. */
.card[class*="tile-"] {
  border-top: 3px solid var(--tile);
}

.card[class*="tile-"] > .row-between .report-section-title,
.card[class*="tile-"] > .report-section-title {
  color: var(--tile);
}

/* ---- Horizontal bar chart ---- */

.chart-hbar-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  position: relative;
  padding: var(--space-1) 0;
}

.chart-hbar-label {
  width: 150px;
  flex-shrink: 0;
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-hbar-track {
  flex: 1;
  background: var(--color-bg-alt);
  border-radius: 6px;
  height: 14px;
  overflow: hidden;
}

.chart-hbar-fill {
  height: 100%;
  border-radius: 6px;
  min-width: 6px;
}

.chart-hbar-value {
  width: 70px;
  flex-shrink: 0;
  text-align: left;
  font-size: 0.8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--color-ink);
  white-space: nowrap;
}

/* ---- Report field grid (label/value pairs) ---- */

.report-section-title {
  font-weight: 700;
  font-size: 0.92rem;
  margin: 0;
  color: var(--color-ink);
}

.report-field-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-2) var(--space-5);
  font-size: 0.9rem;
  margin: 0;
}

.report-field-grid dt {
  color: var(--color-muted);
  display: inline;
  font-weight: 400;
}

.report-field-grid dd {
  display: inline;
  margin-inline-start: var(--space-2);
  font-weight: 600;
}

.report-field-row {
  padding: var(--space-1) 0;
}

@media (max-width: 780px) {
  .report-field-grid {
    grid-template-columns: 1fr;
  }
}

.report-photos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-3);
}

.report-photo {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  transition: opacity 0.15s;
}

.report-photo:hover {
  opacity: 0.85;
}

.report-notes-box {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-size: 0.9rem;
  min-height: 60px;
  white-space: pre-wrap;
  background: var(--color-bg-alt);
}

/* ---- Misc ---- */

.empty-state {
  text-align: center;
  padding: var(--space-7) var(--space-4);
  color: var(--color-muted);
}

.muted {
  color: var(--color-muted);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

/* ---- Login ---- */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-navy);
  padding: var(--space-4);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-lift);
}

.login-brand {
  text-align: center;
  margin-bottom: var(--space-6);
}

.login-brand-logo {
  height: 56px;
  width: auto;
  display: inline-block;
}

.login-brand-sub {
  font-size: 0.85rem;
  color: var(--color-muted);
  margin-top: var(--space-2);
}

.login-error {
  background: var(--color-danger-soft);
  color: var(--color-danger);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

.login-notice {
  background: var(--color-success-soft);
  color: var(--color-success);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

/* ===== PART C — bridge for noursina's legacy Bootstrap 3 markup ========== */

.x {
  font-family: var(--font-family);
  word-spacing: normal;
}

/* .z / .y / .m / .mf / .pa are legacy spacing + direction helpers. Direction
   is now set once on <html dir="rtl">, so they only need neutralising. */
.z {
  direction: rtl;
}
.y {
  padding-left: 0;
}

/* Legacy page titles: backend.css sets h1 to 50px with 40px margins. */
h1 {
  font-size: 1.45rem;
  margin: 0 0 var(--space-5);
}
h1.text-center,
h2.text-center,
h3.text-center {
  text-align: right;
}

/* Bootstrap's fixed-width .container inside the content column */
.page-content .container,
.page-content .container-fluid {
  width: 100%;
  max-width: none;
  padding-right: 0;
  padding-left: 0;
  margin-right: 0;
  margin-left: 0;
}
.page-content > center {
  text-align: right;
}

.btn-success {
  background: var(--color-success);
  border-color: var(--color-success);
  color: #fff;
}
.btn-success:hover:not(:disabled),
.btn-success:focus,
.btn-success:active {
  background: #19703d;
  border-color: #19703d;
  color: #fff;
}
.btn-info {
  background: var(--color-info);
  border-color: var(--color-info);
  color: #fff;
}
.btn-info:hover:not(:disabled),
.btn-info:focus,
.btn-info:active {
  background: var(--color-info-hover);
  border-color: var(--color-info-hover);
  color: #fff;
}
.btn-warning {
  background: var(--color-warning);
  border-color: var(--color-warning);
  color: #fff;
}
.btn-warning:hover:not(:disabled) {
  background: #9c6616;
  border-color: #9c6616;
  color: #fff;
}
.btn-default {
  background: transparent;
  border-color: var(--color-border-strong);
  color: var(--color-ink);
}
.btn-default:hover:not(:disabled),
.btn-default:focus {
  background: var(--color-bg-alt);
  color: var(--color-ink);
}
.btn-block {
  display: flex;
  width: 100%;
}
input.btn,
button.btn {
  line-height: normal;
}

.form-control {
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  font-size: 0.92rem;
  background: var(--color-surface);
  color: var(--color-ink);
  width: 100%;
  height: auto;
  box-shadow: none;
  transition: border-color 0.15s, outline-color 0.15s;
}
.form-control:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
  border-color: var(--color-accent);
  box-shadow: none;
}
textarea.form-control {
  resize: vertical;
  min-height: 80px;
}
select.form-control {
  padding-inline-end: var(--space-5);
}
input[type="file"].form-control {
  padding: var(--space-2) var(--space-3);
  background: var(--color-bg-alt);
  border-style: dashed;
}
.form-control[readonly],
.form-control[disabled] {
  background: var(--color-bg-alt);
  color: var(--color-muted);
}

label,
.control-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-ink-soft);
  margin-bottom: var(--space-1);
}

/* Required-field asterisk injected by backend.js. It is inserted straight
   after the input, and the inputs are display:block/width:100%, so it landed
   on its own line under every field as a stray red dot. Pinning it to the
   top corner of its own .form-group puts it next to the label instead. */
/* backend.js injects this span AFTER the input, so wherever it is placed it
   reads as a stray red dot floating away from the label it belongs to. It is
   hidden, and the required mark is drawn on the label itself instead. */
.asterisk {
  display: none;
}

.ns-section-body > .form-group:has(.asterisk) > label::after,
.form-horizontal .form-group:has(.asterisk) .control-label::after,
.field:has(.asterisk) > label::after {
  content: " *";
  color: var(--color-danger);
  font-weight: 700;
}
.show-pass {
  top: 34px;
  right: 12px;
  left: auto;
  color: var(--color-muted);
  cursor: pointer;
}

/* -- the legacy add/edit field grid (.formadd > .form-group.col-md-N) --
   The float grid is kept so field order is untouched; only rhythm changes. */
/* -- the .form-horizontal pages (add member, add/edit category) --
   These are not built from .formadd, so the sectioning JS never touches them:
   they were rendering as a bare, unstyled form floating in the middle of an
   otherwise empty page, with each label stranded far from its own field.
   They get the same card treatment as everything else, and a two-column
   label/field grid so the rows actually line up. */
.page-content .form-horizontal {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-subtle);
  padding: var(--space-5);
  max-width: 660px;
  margin: 0 0 var(--space-4);
}

/* Label ABOVE the field, not beside it. A two-column grid was tried first and
   measured out as `150px 448px` with the label landing in the 448px track and
   the input squeezed into the 150px one — grid track order runs right-to-left
   in RTL, which makes a fixed label column fragile. Stacking matches the
   property forms and the login screen anyway, so the whole panel reads the
   same way. */
.page-content .form-horizontal .form-group {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  margin: 0 0 var(--space-4);
  float: none;
  width: auto;
}

.page-content .form-horizontal .form-group > div {
  width: 100%;
  min-width: 0;
}

.page-content .form-horizontal .control-label,
.page-content .form-horizontal label {
  text-align: start;
  float: none;
  width: auto;
  padding: 0;
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-ink-soft);
}

.page-content .form-horizontal [class*="col-sm-"],
.page-content .form-horizontal [class*="col-md-"] {
  float: none;
  width: auto;
  min-width: 0;
  padding: 0;
  margin: 0;
}

.page-content .form-horizontal .form-control {
  height: 40px;
  width: 100%;
}

/* Yes / No radio pairs sat stacked with their labels adrift */
.page-content .form-horizontal .form-group > div > div {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-inline-end: var(--space-5);
}
.page-content .form-horizontal .form-group > div > div label {
  font-weight: 500;
  color: var(--color-ink);
}
.page-content .form-horizontal input[type="radio"] {
  margin: 0;
  accent-color: var(--color-accent);
  width: 16px;
  height: 16px;
}

/* the submit row lines up under the fields, not off on its own */
.page-content .form-horizontal .form-group:last-of-type {
  margin-bottom: 0;
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
}
.page-content .form-horizontal .col-sm-offset-2 {
  margin: 0;
}

/* the password reveal eye that backend.js hooks up */
.page-content .form-horizontal .show-pass {
  position: static;
  margin-inline-start: var(--space-2);
  color: var(--color-muted);
}

.formadd {
  margin: 0 calc(-1 * var(--space-2));
}
.formadd::after {
  content: "";
  display: table;
  clear: both;
}
.formadd .form-group {
  position: relative;   /* anchor for the .asterisk above */
  float: right;
  margin: 0 0 var(--space-4);
  padding: 0 var(--space-2);
}
.formadd .form-group > label {
  display: block;
}
.formadd .form-control {
  text-align: right;
}
.formadd .form-row {
  margin: 0;
}
.formadd .form-row .form-control {
  float: none;
  width: 100%;
}

.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  margin-bottom: var(--space-4);
}

.main-table,
.main-table.table {
  width: 100%;
  margin: 0;
  border-collapse: collapse;
  border: 0;
  box-shadow: none;
  font-size: 0.89rem;
  background: var(--color-surface);
}

/* the legacy header row is the first <tr> of <td>s */
.main-table tr:first-child td,
.main-table.table > tbody > tr:first-child > td {
  text-align: right;
  padding: var(--space-3) var(--space-4);
  background: var(--color-bg-alt);
  font-weight: 700;
  color: var(--color-ink-soft);
  border: 0;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
  vertical-align: middle;
}

.main-table td,
.main-table.table > tbody > tr > td,
.main-table.table-bordered > tbody > tr > td {
  padding: var(--space-3) var(--space-4);
  border: 0;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
  background: transparent;
  color: var(--color-ink);
}

.main-table.table > tbody > tr:hover > td {
  background: var(--color-bg-alt);
}
.main-table.table > tbody > tr:first-child:hover > td {
  background: var(--color-bg-alt);
}
.main-table.table > tbody > tr:last-child > td {
  border-bottom: 0;
}

/* the code column reads as an identifier */
.main-table.table > tbody > tr:not(:first-child) > td:first-child {
  font-weight: 700;
  color: var(--color-navy);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.main-table .btn {
  padding: var(--space-1) var(--space-3);
  font-size: 0.8rem;
  margin: 2px;
}
.ns-cell-actions {
  white-space: nowrap;
}

.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-subtle);
  overflow: hidden;
}
.panel-default > .panel-heading {
  background: var(--color-bg-alt);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-ink);
  font-size: 0.92rem;
  font-weight: 700;
  padding: var(--space-3) var(--space-4);
}

.alert {
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding: var(--space-3) var(--space-4);
  font-size: 0.88rem;
  box-shadow: none;
}
.alert-success {
  background: var(--color-success-soft);
  border-color: transparent;
  color: var(--color-success);
}
.alert-danger {
  background: var(--color-danger-soft);
  border-color: transparent;
  color: var(--color-danger);
}
.alert-info {
  background: var(--color-info-soft);
  border-color: transparent;
  color: var(--color-info);
}
.alert-warning {
  background: var(--color-warning-soft);
  border-color: transparent;
  color: var(--color-warning);
}

/* -- the "add property" chooser (addproperty.php) --
   The seven add-forms used to be printed as a strip of buttons on top of
   every add/edit form (include/templats/addproperty.php). They now live in
   the "إضافة عقار" dropdown, and this grid is only the chooser page itself. */
.ns-choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: var(--space-4);
}

.ns-choice {
  display: block;
  background: var(--tile-soft, var(--color-surface));
  border: 1px solid var(--color-border);
  border-inline-start: 4px solid var(--tile, var(--color-navy));
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  box-shadow: var(--shadow-subtle);
  transition: transform 0.15s, box-shadow 0.15s;
}
.ns-choice:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lift);
}
/* display:block matters: both are <span>s, and inline they ran together into
   one line ("شقق كاش / قانون / مفروششقة أو إستوديو…"). */
.ns-choice-title {
  display: block;
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--tile, var(--color-ink));
}
.ns-choice-sub {
  display: block;
  font-size: 0.8rem;
  color: var(--color-ink-soft);
  margin-top: 2px;
}

/* -- categories page (legacy .categories markup) -- */
.categories .cat {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  position: relative;
  overflow: hidden;
}
.categories .cat:hover {
  background: var(--color-bg-alt);
}
.categories .cat:last-of-type {
  border-bottom: 0;
}
.categories .cat h3 {
  font-size: 0.98rem;
  font-weight: 700;
  margin: 0 0 var(--space-1);
}
.categories .cat p {
  color: var(--color-muted);
  font-size: 0.85rem;
  margin: 0 0 var(--space-2);
}
.categories hr {
  display: none;
}
.categories .cat .hidden-buttons {
  position: static;
  right: auto;
  top: auto;
  float: left;
}
.categories .cat .visibility,
.categories .cat .commenting,
.categories .cat .advertises {
  display: inline-block;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px var(--space-2);
  margin-inline-end: var(--space-1);
  background: var(--color-border);
  color: var(--color-muted);
}
.categories .add-category {
  margin: var(--space-1) 0 var(--space-5);
}

/* -- project tiles (Madinaty / Rehab image menus) -- */
.page-content .row.text-center {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin: 0;
}
a.y > img {
  width: 100%;
  max-width: 230px;
  height: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  padding: var(--space-1);
  background: var(--color-surface);
}

/* -- image thumbnails / lightbox -- */
.img-thumbnail {
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  padding: 3px;
  background: var(--color-surface);
}
.gallery,
.ns-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.ns-gallery .img-thumbnail {
  width: 118px;
  height: 118px;
  object-fit: cover;
}

/* -- legacy dashboard tiles, kept in case an old page still renders them -- */
.home-stats .stat {
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  font-size: 0.85rem;
  box-shadow: var(--shadow-subtle);
}
.home-stats .stat span {
  font-size: 1.7rem;
}

/* -- misc legacy helpers from backstyle.css -- */
.commdiv {
  margin-top: var(--space-5);
  height: auto;
  background: var(--color-surface);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
}
.section-content {
  width: auto;
  height: auto;
  margin-top: 0;
}
.bg-theme-colored,
.bg-theme-colored2,
.bg-theme-colored3 {
  height: auto;
  min-height: 120px;
  border-radius: var(--radius-lg);
}
.medbox {
  width: auto;
  height: auto;
  margin-top: 0;
  padding: var(--space-4);
}
.qstm {
  margin-top: var(--space-3);
}

.ns-filterbar,
.page-content .container.ns-filterbar,
.page-content .container-fluid.ns-filterbar {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-subtle);
  padding: var(--space-4) var(--space-5) var(--space-2);
  margin-bottom: var(--space-4);
}
.ns-filterbar-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--color-ink);
  margin-bottom: var(--space-3);
}
.ns-filterbar-head .fa {
  color: var(--color-accent);
}
/* The legacy search markup nests Bootstrap columns inside a .formadd wrapper
   (.formadd.col-md-12 > .form-group.col-md-2 ...). An earlier version here
   only made `form` and `.form-group` flex, never `.formadd`, so on Search.php
   every field stacked into one narrow right-hand column with three quarters of
   the page left empty. Each level is now an explicit wrap-row, and each field
   group is a label-over-control column. */
.ns-filterbar form.form-inline,
.ns-filterbar .formadd,
.ns-filterbar > .form-group {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-3);
  float: none;
  margin: 0 0 var(--space-3);
  padding: 0;
  /* 100%, not auto: .formadd also carries Bootstrap's .col-md-12, so it keeps
     `float: left`, and a floated box with width:auto shrink-wraps — which
     squeezed the whole Search.php filter set into the right-hand half of the
     card and wrapped every field onto its own line. */
  width: 100%;
}
/* .formadd sits inside the form as a FLEX ITEM, so `width: 100%` alone was
   not enough: flex-shrink defaults to 1 and Chrome shrank it to its content
   width (measured: 672px inside a 1226px form), which is what kept the whole
   Search.php filter set bunched into the right-hand half. Pinning the basis
   AND forbidding shrink is what actually holds the full line. */
.ns-filterbar .formadd {
  flex: 1 1 100%;
  min-width: 0;
}

/* One row model for every field group, NOT a label-over-control column.
   A column was right for Search.php, where each .form-group holds a single
   field, but wrong for Items.php, where one .form-group holds the three
   quick-search boxes plus the button — measuring showed that group being
   forced to flex-direction:column and 190px wide, which stacked the three
   boxes vertically. A wrapping row is correct for both shapes. */
.ns-filterbar .form-group {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  flex: 0 1 auto;
  float: none;
  margin: 0;
  padding: 0;
  width: auto;
  position: static;
}
.ns-filterbar .form-control {
  display: block;
  flex: 0 1 170px;
  min-width: 120px;
  width: auto;
  margin: 0;
}
/* a date pair or a from/to pair keeps its two boxes together */
.ns-filterbar .form-row .form-control {
  flex: 0 1 130px;
}
.ns-filterbar .form-row {
  display: flex;
  gap: var(--space-2);
  margin: 0;
}
.ns-filterbar label,
.ns-filterbar .mf {
  margin: 0;
  font-size: 0.82rem;
  color: var(--color-muted);
  flex: 0 0 auto;
  white-space: nowrap;
}
.ns-filterbar .btn,
.ns-filterbar input[type="submit"] {
  flex: 0 0 auto;
  align-self: flex-end;
}
.ns-filterbar [class*="col-md-"],
.ns-filterbar [class*="col-sm-"] {
  float: none;
  width: auto;
  padding: 0;
}
.ns-filterbar br {
  display: none;
}
.ns-filterbar hr {
  margin: var(--space-3) 0;
  border-color: var(--color-border);
}

/* a legacy heading centred by its wrapper (<div class="text-center"><h1>) */
.page-content .text-center > h1 {
  text-align: right;
}

/* Server-rendered "?Page=" pagination row */
.ns-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  margin: var(--space-4) 0 var(--space-2);
  font-size: 0.85rem;
  color: var(--color-muted);
}
.ns-pager a,
.ns-pager .ns-pager-current {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 var(--space-2);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.ns-pager a:hover {
  background: var(--color-bg-alt);
  color: var(--color-ink);
}
.ns-pager .ns-pager-current {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}
.ns-pager .ns-pager-sep {
  display: none;
}
.ns-pager .ns-pager-text {
  color: var(--color-muted);
  padding: 0 var(--space-1);
}

.ns-form-sections {
  clear: both;
}
.ns-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-subtle);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-4);
}
.ns-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  width: 100%;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: right;
  font-family: inherit;
}
.ns-section-count {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-muted);
  margin-inline-start: auto;
}
.ns-section-caret {
  color: var(--color-muted);
  font-size: 0.7rem;
  transition: transform 0.15s;
}
.ns-section.is-collapsed .ns-section-caret {
  transform: rotate(90deg);
}
/* The legacy markup lays fields out with floats and Bootstrap column widths
   (col-md-2 next to col-md-4 next to col-md-12), which is why the rows never
   lined up: a row of six fields sat above a row of four that started at a
   different offset, and short sections left two thirds of the card empty.
   A real grid ignores those widths and gives every field one equal, aligned
   column — no markup changes, so every field name stays exactly as it was. */
.ns-section-body {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: var(--space-4);
  align-items: start;
  padding-top: var(--space-4);
}

.ns-section-body > .form-group,
.ns-section-body > .form-group[class*="col-"] {
  display: flex;
  flex-direction: column;
  gap: 6px;
  float: none;
  width: auto;
  max-width: none;
  min-width: 0;
  margin: 0;
  padding: 0;
}

/* Several fields are deliberately hidden in the markup (the floor and stage
   selects, the member and usernamupdata inputs) — they still submit, they are
   just not shown. `display: flex` above beats the browser's own
   [hidden] { display: none }, which made them reappear as duplicate "الدور"
   and "المرحلة" fields; this puts them back out of sight. */
.ns-section-body > .form-group[hidden] {
  display: none;
}

.ns-section-body > .form-group > label {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-ink-soft);
}

.ns-section-body .form-control {
  width: 100%;
  height: 40px;
}
.ns-section-body textarea.form-control {
  height: auto;
  min-height: 92px;
}
.ns-section-body input[type="file"].form-control {
  height: auto;
  padding: var(--space-3);
  border-style: dashed;
  background: var(--color-bg-alt);
  cursor: pointer;
}

/* the legacy inner wrapper some fields carry */
.ns-section-body .form-row {
  display: block;
  margin: 0;
}
.ns-section-body .form-row .form-control {
  width: 100%;
  float: none;
}

.ns-section-body > .ns-field-wide {
  grid-column: 1 / -1;
}

.ns-section.is-collapsed .ns-section-body {
  display: none;
}

/* Action row at the end of a sectioned form */
.ns-formbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
  margin-bottom: var(--space-4);
}
.ns-formbar > .form-group {
  float: none !important;
  margin: 0 !important;
  padding: 0 !important;
  width: auto !important;
}
.ns-formbar .col-sm-offset-2 {
  margin: 0;
}
.ns-formbar-hint {
  font-size: 0.8rem;
  color: var(--color-muted);
  margin-inline-start: auto;
}

/* Page toolbar (primary action promoted next to the page title) */
.ns-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}
.ns-toolbar-end {
  margin-inline-start: auto;
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* Compact record list (dashboard "latest", members) */
.ns-list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.ns-list li {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.88rem;
}
.ns-list li:last-child {
  border-bottom: 0;
}
.ns-list-id {
  flex: 0 0 auto;
  min-width: 46px;
  font-weight: 700;
  color: var(--color-navy);
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem;
}
.ns-list-main {
  min-width: 0;
  flex: 1 1 auto;
}
.ns-list-title {
  display: block;
  color: var(--color-ink);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ns-list-sub {
  display: block;
  font-size: 0.78rem;
  color: var(--color-muted);
}
.ns-list-end {
  margin-inline-start: auto;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.ns-count-note {
  font-size: 0.85rem;
  color: var(--color-muted);
  margin-bottom: var(--space-4);
}

/* ===== PART E — responsive ============================================== */

@media (max-width: 991px) {
  .page-content {
    padding: var(--space-4);
  }
}

@media (max-width: 767px) {
  .page-content {
    padding: var(--space-3);
  }
  h1 {
    font-size: 1.2rem;
  }

  /* the legacy float grid collapses so add/edit forms stop crowding */
  .formadd .form-group,
  .formadd .form-group[class*="col-"] {
    float: none;
    width: 100%;
  }
  .form-horizontal .control-label {
    text-align: right;
  }

  
  .table-responsive {
    border: 0;
    background: transparent;
    overflow: visible;
  }
  .main-table,
  .main-table.table,
  .main-table tbody,
  .main-table tr,
  .main-table td,
  .main-table.table > tbody > tr,
  .main-table.table > tbody > tr > td {
    display: block;
    width: auto;
  }
  .main-table.table > tbody > tr:first-child {
    display: none;
  }
  .main-table.table > tbody > tr {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-subtle);
    margin-bottom: var(--space-3);
    padding: var(--space-1) 0;
  }
  .main-table.table > tbody > tr > td {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--color-border);
    text-align: right;
  }
  .main-table.table > tbody > tr > td:last-child {
    border-bottom: 0;
  }
  .main-table td[data-ns-label]::before {
    content: attr(data-ns-label);
    flex: 0 0 40%;
    max-width: 40%;
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--color-muted);
  }

  .ns-filterbar {
    padding: var(--space-3) var(--space-3) var(--space-1);
  }
  .ns-filterbar form.form-inline .form-control,
  .ns-filterbar .form-group .form-control {
    flex: 1 1 100%;
    min-width: 0;
    width: 100%;
  }

  .report-field-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1024px) {
  .top-nav {
    position: relative;
    gap: var(--space-3);
    padding: 0 var(--space-3);
  }

  .top-nav-burger {
    display: inline-flex;
  }

  .top-nav-sections {
    position: absolute;
    top: 56px;
    right: 0;
    left: 0;
    z-index: 30;
    display: none;
    flex-direction: column;
    align-items: stretch;
    height: auto;
    max-height: calc(100vh - 56px);
    overflow-y: auto;
    padding: var(--space-2);
    background: var(--color-navy);
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: var(--shadow-lift);
  }
  body.ns-nav-open .top-nav-sections {
    display: flex;
  }

  .top-nav-section {
    display: block;
  }
  .top-nav-label {
    width: 100%;
    height: auto;
    padding: var(--space-3);
    justify-content: space-between;
    border-radius: var(--radius-sm);
  }
  .top-nav-label.active {
    box-shadow: none;
    background: rgba(255, 255, 255, 0.12);
  }

  .top-nav-dropdown {
    position: static;
    min-width: 0;
    margin: 0 var(--space-2) var(--space-2);
    max-height: none;
    box-shadow: none;
  }

  .top-nav-user {
    margin-inline-start: auto;
  }
  .top-nav-user .btn {
    padding: var(--space-1) var(--space-2);
    font-size: 0.75rem;
  }
}

:root {
  --ns-root-size: 17px;    /* browser default is 16px */
  --ns-topnav-h: 60px;     /* was 56px */
  --ns-control-h: 42px;    /* was 40px */
}

html {
  font-size: var(--ns-root-size);
}

body {
  font-size: 1rem;         /* was a fixed 15px, so it never scaled */
  line-height: 1.6;
}

.top-nav {
  height: var(--ns-topnav-h);
}

.top-nav-logo {
  height: 30px;
}

.top-nav-burger {
  width: 38px;
  height: 38px;
}

.top-nav-dropdown {
  max-height: calc(100vh - var(--ns-topnav-h) - var(--space-3));
}

.global-search-input {
  padding-top: 8px;
  padding-bottom: 8px;
}

/* a bigger column floor, so the wider text still fits a field per column */
.ns-section-body {
  grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
}

.ns-section-body .form-control,
.page-content .form-horizontal .form-control {
  height: var(--ns-control-h);
}

.ns-pager a,
.ns-pager .ns-pager-current {
  min-width: 34px;
  height: 34px;
}

@media (min-width: 1025px) {
  .top-nav-sections {
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }
  .top-nav-sections::-webkit-scrollbar {
    display: none;
  }
  .top-nav-dropdown {
    position: fixed;
    top: auto;
    right: auto;
  }
}

/* trim the labels so the row fits: 1016px -> 866px, no section dropped */
@media (min-width: 1025px) and (max-width: 1700px) {
  .top-nav-sections {
    gap: 0;
  }
  .top-nav-label {
    padding: 0 var(--space-2);
    font-size: 0.80rem;
  }
  .global-search {
    width: 170px;
  }
}

/* the hamburger panel hangs off the bar, so it follows the new height */
@media (max-width: 1024px) {
  .top-nav-sections {
    top: var(--ns-topnav-h);
    max-height: calc(100vh - var(--ns-topnav-h));
  }
}

/* ===== PART H — density at the new scale ================================
   Raising the root size made two places too tight. Both are measured, not
   guessed:

   1. items.php has a 15-column table. At 1440 it needed 1415px inside a
      1359px box, so the last column (the حذف button) sat 8px past the edge
      and the date and address cells wrapped onto two lines. The table is
      inside .table-responsive and did scroll, but a table you must scroll to
      reach the action buttons is a table that looks broken. Trimming the
      cell padding from 12/16 to 10/10 gives back ~12px per column — about
      180px over fifteen columns — which is more than the 56px it was over.

   2. The filter card stacked its four search forms as four full-width rows,
      each holding a label and one or two small boxes, so more than half the
      card was empty. They now flow two per row. */

@media (max-width: 1600px) {
  .main-table td,
  .main-table.table > tbody > tr > td,
  .main-table.table-bordered > tbody > tr > td,
  .main-table tr:first-child td,
  .main-table.table > tbody > tr:first-child > td {
    padding: var(--space-2) 10px;
  }
  .main-table .btn {
    padding: var(--space-1) var(--space-2);
    margin: 1px;
  }
}

.main-table td.ns-cell-plain {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* The card held four full-width rows, each with a label and one small box,
   so it ran 353px tall with more than half of it empty. Measured structure
   on items.php: a head, the three-box quick search, then ONE .form-group
   wrapper holding the three single-field forms. So the wrapper becomes the
   row that carries its three forms side by side, and the quick search — the
   only one wide enough to need it — keeps a row of its own. */
@media (min-width: 900px) {
  .ns-filterbar,
  .page-content .container.ns-filterbar,
  .page-content .container-fluid.ns-filterbar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
    gap: var(--space-2) var(--space-5);
    align-items: start;
  }
  .ns-filterbar-head,
  .ns-filterbar hr,
  .ns-filterbar > .form-group,
  .ns-filterbar > form.form-inline {
    grid-column: 1 / -1;
  }

  .ns-filterbar > .form-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-5);
  }
  /* these carry Bootstrap's .col-md-4 and the width:100% set further up,
     which is what stacked them one per line */
  .ns-filterbar > .form-group > form.form-inline {
    flex: 0 1 auto;
    width: auto;
    margin-bottom: 0;
  }
}

/* ===== PART I — the page shown after an action ==========================
   Every add / edit / delete ends in redirectHome(), which used to print a
   bare Bootstrap alert ("0Record Updated"), a second alert quoting the raw
   URL it was about to jump to, and — on pages without ob_start() — a PHP
   warning about headers. It now prints one card, in Arabic. */

.ns-result {
  max-width: 560px;
  margin: var(--space-6) auto;
  padding: var(--space-6) var(--space-5) var(--space-5);
  text-align: center;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-top: 4px solid var(--color-muted);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-subtle);
}

.ns-result-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin: 0 auto var(--space-4);
  border-radius: 50%;
  font-size: 1.6rem;
  color: #fff;
  background: var(--color-muted);
}

.ns-result-title {
  margin: 0 0 var(--space-2);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-ink);
}

.ns-result-text {
  margin: 0;
  font-size: 1rem;
  line-height: 1.7;
  color: var(--color-ink-soft);
}

.ns-result-meta {
  margin: var(--space-2) 0 0;
  font-size: 0.85rem;
  color: var(--color-muted);
}

/* per-file upload problems listed under the result message */
.ns-result-issues {
  margin: var(--space-2) auto 0;
  padding: var(--space-3) var(--space-4);
  max-width: 440px;
  list-style: none;
  text-align: right;
  font-size: 0.85rem;
  line-height: 1.7;
  color: var(--color-ink-soft);
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.ns-result-issues li + li {
  margin-top: var(--space-1);
  padding-top: var(--space-1);
  border-top: 1px dashed var(--color-border);
}

.ns-result-actions {
  margin: var(--space-5) 0 var(--space-3);
}

.ns-result-actions .btn {
  min-width: 160px;
}

.ns-result-note {
  margin: 0;
  font-size: 0.82rem;
  color: var(--color-muted);
}

.ns-result-note span {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--color-ink-soft);
}

.ns-result-success {
  border-top-color: var(--color-success);
}
.ns-result-success .ns-result-icon {
  background: var(--color-success);
}

.ns-result-danger {
  border-top-color: var(--color-accent);
}
.ns-result-danger .ns-result-icon {
  background: var(--color-accent);
}

.ns-result-info {
  border-top-color: var(--color-info);
}
.ns-result-info .ns-result-icon {
  background: var(--color-info);
}

.ns-result-warning {
  border-top-color: var(--color-warning);
}
.ns-result-warning .ns-result-icon {
  background: var(--color-warning);
}

/* the page heading above the card ("تعديل عضو") is context, not a banner */
.page-content .ns-result + * {
  margin-top: var(--space-5);
}

@media (min-width: 900px) {
  .page-content .form-horizontal:not(:has(.ns-section)) {
    max-width: 760px;
    margin-inline: auto;
  }
}

@media (max-width: 600px) {
  .ns-result {
    margin: var(--space-4) 0;
    padding: var(--space-5) var(--space-4);
  }
}

/* ===== PART J — photo repair ============================================
   Screens that review 1,280 orphaned photo files. GD is not loaded on this
   installation, so there are no server-side thumbnails: the grid constrains
   the images with CSS and the browser does the scaling, and the page shows
   twelve upload groups at a time so a page never loads the whole library. */

.ns-card-body {
  /* neutral wrapper; .card already supplies the padding */
}

.ns-photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--space-3);
  align-items: start;
}

.ns-photo {
  position: relative;
  margin: 0;
  padding: 0;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.ns-photo img {
  display: block;
  width: 100%;
  height: 130px;
  object-fit: cover;
  background: var(--color-bg-alt);
}

.ns-photo figcaption {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2);
}

.ns-photo.is-cover {
  border-color: var(--color-success);
  box-shadow: inset 0 0 0 2px var(--color-success);
}

.ns-photo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0;
}

/* a whole tile is the checkbox target, so review is one click per photo */
.ns-photo-pick {
  display: block;
  cursor: pointer;
}

.ns-photo-pick input[type="checkbox"] {
  position: absolute;
  top: 8px;
  inset-inline-end: 8px;
  width: 20px;
  height: 20px;
  accent-color: var(--color-accent);
  cursor: pointer;
  z-index: 2;
}

.ns-photo-pick:has(input:checked) {
  border-color: var(--color-accent);
  box-shadow: inset 0 0 0 3px var(--color-accent);
}

/* the action bar follows the page while the admin scrolls through groups */
.ns-repair-bar {
  position: sticky;
  top: var(--ns-topnav-h);
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-subtle);
}

.ns-repair-bar strong {
  color: var(--color-accent);
}

.ns-inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.ns-inline-form .form-control {
  flex: 1 1 320px;
  min-width: 0;
}

.ns-repair-results {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.ns-choice-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: 0;
  padding: var(--space-3);
  font-weight: 400;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
}

.ns-choice-row:hover {
  border-color: var(--color-info);
}

.ns-choice-row > span {
  flex: 1;
}

.ns-choice-row input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--color-accent);
}

.ns-batch-all {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  font-size: 0.85rem;
  color: var(--color-muted);
  cursor: pointer;
}

/* the cover photo is marked in the property report too */
.report-photo.is-cover {
  outline: 3px solid var(--color-success);
  outline-offset: -3px;
}

.ns-empty {
  margin: 0;
  padding: var(--space-5);
  text-align: center;
  color: var(--color-muted);
  background: var(--color-bg-alt);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
}

/* ===== PART K — commissions =============================================
   The commission screens: filter grid, form grid, and the live calculation
   card. Same tokens as the rest of the panel, no new colours. */

.badge-default {
  background: var(--color-bg-alt);
  color: var(--color-ink-soft);
  border: 1px solid var(--color-border);
}

/* a two-to-four column grid that collapses cleanly on a phone */
.ns-form-grid,
.ns-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: var(--space-4);
  align-items: start;
}

.ns-form-grid .field,
.ns-filter-grid .field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.ns-form-grid label,
.ns-filter-grid label {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-ink-soft);
}

/* ---- the calculation card --------------------------------------------- */

.ns-calc-card {
  border-top: 3px solid var(--color-info);
}

.ns-calc-formula {
  margin: 0 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
  font-size: 0.85rem;
  line-height: 1.9;
  color: var(--color-ink-soft);
  background: var(--color-bg-alt);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
}

.ns-calc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-3);
}

.ns-calc-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: var(--space-4);
  text-align: center;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.ns-calc-cell span {
  font-size: 0.82rem;
  color: var(--color-muted);
}

.ns-calc-cell strong {
  font-size: 1.35rem;
  font-variant-numeric: tabular-nums;
  color: var(--color-ink);
}

.ns-calc-cell.is-net {
  background: var(--color-success-soft);
  border-color: var(--color-success);
}

.ns-calc-cell.is-net strong {
  color: var(--color-success);
}

.ns-calc-note {
  margin: var(--space-3) 0 0;
  font-size: 0.8rem;
  color: var(--color-muted);
}

.ns-calc-table td:last-child {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.ns-override {
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px dashed var(--color-border);
}

.ns-formbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: end;
}

.ns-formbar .form-control {
  min-width: min(100%, 310px);
}

.ns-choice-list {
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.ns-choice-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-alt);
}

.ns-result-meta {
  margin: var(--space-3) 0 0;
  color: var(--color-muted);
  font-size: 0.85rem;
}

/* ===== PART L — "اختر أو اكتب" filter fields ============================
   A filter is now <input list="…"> with a <datalist>: the same box accepts a
   choice from the list and free typing. Browsers draw the list button very
   faintly, so the caret is painted here to make it obvious the box opens. */

/* The browser already draws a button that opens the list and places it on the
   correct side in RTL. It is only too faint to notice, so it is darkened
   rather than replaced — a hand-painted caret would sit on the wrong side of
   an RTL field and would not be clickable. */
.ns-combo::-webkit-calendar-picker-indicator {
  opacity: 0.45;
  cursor: pointer;
}

.ns-combo:hover::-webkit-calendar-picker-indicator,
.ns-combo:focus::-webkit-calendar-picker-indicator {
  opacity: 1;
}

/* ===== PART M — tabs (شاشة التصنيفات) ================================== */

.ns-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: var(--space-5) 0 var(--space-4);
}

.ns-tab {
  padding: var(--space-2) var(--space-4);
  font-size: 0.86rem;
  color: var(--color-ink-soft);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  text-decoration: none;
}

.ns-tab:hover {
  border-color: var(--color-info);
  color: var(--color-ink);
}

.ns-tab.is-active {
  color: #fff;
  background: var(--color-navy);
  border-color: var(--color-navy);
}

/* inline edit rows inside the reference tables stay on one line */
.main-table .ns-inline-form {
  flex-wrap: nowrap;
  gap: var(--space-2);
}

.main-table .ns-inline-form .form-control {
  flex: 1 1 160px;
  min-width: 120px;
}

/* ===== PART F — print =================================================== */

@page {
  size: A4;
  margin: 10mm 12mm;
}

@media print {
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  .no-print,
  .top-nav,
  .ns-filterbar,
  .ns-pager,
  .ns-toolbar,
  .ns-formbar,
  .back-link {
    display: none !important;
  }
  /* .app-shell / .main-area are a fixed-header + inner-scroll layout, which
     print has no concept of — without this the page clips after one screen. */
  .app-shell {
    display: block !important;
    height: auto !important;
    overflow: visible !important;
  }
  .main-area {
    display: block !important;
    overflow: visible !important;
  }
  .page-content {
    padding: 0 !important;
  }
  .table-responsive,
  .table-wrap {
    overflow: visible !important;
  }
  body {
    background: #fff;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* ===== PART I — laptops keep the top bar =================================
   The bar used to fold into the burger panel below 1400px, so every 1280 /
   1366 laptop (and 1536 at 125% scaling, which is 1229 CSS px) got a side
   panel instead of the menu. The burger is now for tablets and phones
   (≤1024px); from 1025px the row stays a row, tightened below 1366px so the
   seven sections, the search box and the user menu fit on one line. */
@media (min-width: 1025px) and (max-width: 1365px) {
  .top-nav {
    gap: var(--space-2);
    padding: 0 var(--space-3);
  }
  .top-nav-label {
    padding: 0 6px;
    font-size: 0.76rem;
  }
  .top-nav-user-name {
    display: none;
  }
  .global-search {
    width: 150px;
  }
}

/* ===== PART J — the lists' one search box ================================
   items.php and the other property lists: a single box (code, owner name or
   mobile) that filters the table as you type — see layout/js/livesearch.js. */
.ns-live-search {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  max-width: 640px;
  margin: 0 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #e5e7eb);
  border-radius: var(--radius-md, 12px);
  box-shadow: var(--shadow-sm, none);
}
.ns-live-search .ns-live-label {
  margin: 0;
  font-weight: 700;
  white-space: nowrap;
}
.ns-live-search .form-control {
  flex: 1 1 auto;
  min-width: 0;
  height: var(--ns-control-h, 42px);
}
.ns-live-search .ns-live-code {
  flex: 0 1 9rem;
}
@media (max-width: 560px) {
  .ns-live-search { flex-wrap: wrap; }
  .ns-live-search .ns-live-label { flex: 0 0 3.5rem; }
  .ns-live-search .form-control,
  .ns-live-search .ns-live-code { flex: 1 1 calc(100% - 3.5rem - var(--space-3)); }
}
#ns-live-results[aria-busy="true"] {
  opacity: 0.55;
  transition: opacity 0.15s;
}

/* ===== PART K — the property table on laptop widths ========================
   Measured: at 1280px the 15-column list was 28px wider than its box and
   the last column (حذف) was cut at the edge; at 1100px about 150px. Below
   1366px the cells, text and row buttons get tighter so the whole row,
   buttons included, fits without scrolling sideways. */
@media (min-width: 1025px) and (max-width: 1365px) {
  .main-table,
  .main-table.table {
    font-size: 0.8rem;
  }
  .main-table td,
  .main-table.table > tbody > tr > td,
  .main-table.table-bordered > tbody > tr > td,
  .main-table tr:first-child td,
  .main-table.table > tbody > tr:first-child > td {
    padding: 6px 5px;
  }
  .main-table .btn {
    padding: 2px 7px;
    font-size: 0.74rem;
    margin: 1px 0;
  }
  .main-table .badge {
    padding: 2px 6px;
    font-size: 0.7rem;
  }
}

/* ===== PART L — photos on the edit page ================================== */
/* «إضافة صور»: many photos at once, saved on choosing (photoupload.js) */
.ns-photo-add { margin-bottom: var(--space-4); }
.ns-photo-drop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 22px 16px;
  border: 2px dashed var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-bg, #f7f7f9);
  color: var(--color-muted);
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background-color .2s;
}
.ns-photo-drop:hover, .ns-photo-drop.is-over, .ns-photo-drop:focus-within {
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
}
.ns-photo-drop input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}
.ns-photo-drop .fa { font-size: 1.8rem; color: var(--color-accent); }
.ns-photo-drop strong { color: var(--color-ink, #14163d); font-size: 1rem; }
.ns-photo-drop span { font-size: .85rem; }
.ns-photo-add.is-busy .ns-photo-drop { opacity: .6; pointer-events: none; }
.ns-photo-add-submit { margin-top: var(--space-2); }
.ns-photo-js .ns-photo-add-submit { display: none; }
.ns-photo-status { margin-top: var(--space-2); font-weight: 700; color: var(--color-success, #1f8a4c); }
.ns-photo-status:empty { display: none; }
.ns-photo-status.is-error { color: var(--color-danger); }
.ns-photo-status ul { margin: 4px 0 0; padding-inline-start: 18px; font-weight: 400; }
.ns-photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: var(--space-3);
}
.ns-photo {
  margin: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-surface);
}
.ns-photo.is-cover {
  border-color: var(--color-success, #1f8a4c);
  box-shadow: 0 0 0 2px rgba(31, 138, 76, 0.25);
}
.ns-photo img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}
.ns-photo figcaption {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2);
}
.ns-photo figcaption form {
  display: inline;
  margin: 0;
}

/* ===== PART M — property rows are links ===================================
   The whole row opens the property (layout/js/panel.js initRowLinks); edit
   and delete moved onto the property page. */
.main-table tr.ns-row-link {
  cursor: pointer;
}
.main-table tr.ns-row-link:hover > td {
  background: rgba(20, 22, 61, 0.045);
}
.main-table a.ns-row-code {
  font-weight: 700;
  color: inherit;
  text-decoration: none;
}
.main-table tr.ns-row-link:hover a.ns-row-code,
.main-table a.ns-row-code:focus-visible {
  color: var(--color-accent, #e11d2e);
  text-decoration: underline;
}

/* ===== PART N — the permission grid on a user's page ==================== */
.ns-access {
  margin: var(--space-4) 0;
}
.ns-access .card-title {
  margin-bottom: var(--space-3);
}
.ns-access-role {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}
.ns-access-role label {
  font-weight: 600;
  margin: 0;
}
.ns-access-grid {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}
.ns-access-grid[disabled] {
  opacity: 0.45;
}
.ns-access-tools {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.ns-access-table td {
  text-align: center;
  vertical-align: middle;
}
.ns-access-table td.ns-access-section {
  text-align: start;
  font-weight: 700;
  white-space: nowrap;
}
.ns-access-cell {
  display: inline-flex;
  margin: 0;
  padding: 4px 10px;
  cursor: pointer;
}
.ns-access-cell input,
.ns-access-extra input {
  width: 18px;
  height: 18px;
  cursor: pointer;
}
.ns-access-na {
  color: var(--color-muted);
}
.ns-access-extras td {
  text-align: start !important;
  background: rgba(20, 22, 61, 0.025);
}
.ns-access-extra {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 2px var(--space-4) 2px 0;
  font-weight: 500;
}
.ns-access-extra small {
  color: var(--color-muted);
}
.ns-access-switches {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  margin-top: var(--space-3);
}

/* Property photos: one large photo that slides smoothly to the next
   (partials/photoslider.ejs + photoslider.js). */
.ns-slider {
  position: relative;
  width: 100%;
  aspect-ratio: 2.25 / 1;
  max-height: 540px;
  margin: 0 0 var(--space-4);
  background: #121212;
  border-radius: 14px;
  overflow: hidden;
  outline: none;
  user-select: none;
  -webkit-user-select: none;
}
.ns-slider:focus-visible { box-shadow: 0 0 0 3px var(--color-accent-soft), 0 0 0 5px var(--color-accent); }
.ns-slider-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  direction: ltr;
  touch-action: pan-y;
}
.ns-slider-track {
  display: flex;
  height: 100%;
  transition: transform .6s cubic-bezier(.22, .61, .36, 1);
  will-change: transform;
}
.ns-slider-track.is-dragging { transition: none; cursor: grabbing; }
/* last photo → first: a quick fade instead of racing past every photo */
.ns-slider-track.is-jump { transition: none; animation: ns-slide-fade .45s ease; }
@keyframes ns-slide-fade { from { opacity: .25; } to { opacity: 1; } }
.ns-slide {
  position: relative;
  flex: 0 0 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  cursor: zoom-in;
}
/* the same photo, blurred, fills the bars around a tall or narrow photo */
.ns-slide-blur {
  position: absolute;
  inset: -30px;
  width: calc(100% + 60px);
  height: calc(100% + 60px);
  object-fit: cover;
  filter: blur(24px) brightness(.55);
  pointer-events: none;
}
.ns-slide-img {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: scale(1.04);
  transition: transform 1.2s ease;
  pointer-events: none;
}
.ns-slide.is-active .ns-slide-img { transform: scale(1); }
.ns-slide-content {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  padding: 36px 24px 44px;
  color: #fff;
  direction: rtl;
  text-align: right;
  background: linear-gradient(transparent, rgba(0, 0, 0, .78));
  pointer-events: none;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity .5s ease .25s, transform .5s ease .25s;
}
.ns-slide.is-active .ns-slide-content { opacity: 1; transform: none; }
.ns-slide-name { font-size: clamp(1rem, 2vw, 1.5rem); font-weight: 800; }
.ns-slide-des { margin-top: 4px; font-size: .95rem; line-height: 1.5; }
.ns-slider-count {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font-size: .8rem;
  font-weight: 700;
  direction: ltr;
  pointer-events: none;
}
.ns-slider-arrow {
  position: absolute;
  top: 50%;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  margin-top: -23px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .88);
  color: #111;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
  cursor: pointer;
  opacity: .85;
  transition: opacity .2s, transform .2s, background-color .2s;
}
.ns-slider-arrow svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.ns-slider-prev { left: 14px; }
.ns-slider-next { right: 14px; }
.ns-slider:hover .ns-slider-arrow { opacity: 1; }
.ns-slider-arrow:hover, .ns-slider-arrow:focus-visible { background: #fff; transform: scale(1.08); }
.ns-slider-dots {
  position: absolute;
  inset-inline: 0;
  bottom: 14px;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
  padding: 0 60px;
  direction: ltr;
}
.ns-slider-dot {
  width: 8px;
  height: 8px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, .5);
  cursor: pointer;
  transition: width .35s ease, background-color .35s ease;
}
.ns-slider-dot.is-active { width: 24px; background: #fff; }
@media (prefers-reduced-motion: reduce) {
  .ns-slider-track, .ns-slide-img, .ns-slide-content, .ns-slider-dot { transition: none; }
  .ns-slider-track.is-jump { animation: none; }
}
.ns-viewer {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .92);
  cursor: zoom-out;
}
.ns-viewer[hidden] { display: none; }
.ns-viewer img { max-width: 94vw; max-height: 92vh; object-fit: contain; cursor: default; }
.ns-viewer-close {
  position: absolute;
  top: 14px;
  left: 18px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .15);
  color: #fff;
  font-size: 1.8rem;
  cursor: pointer;
}
body.ns-viewer-open { overflow: hidden; }
@media (max-width: 767px) {
  .ns-slider { aspect-ratio: 1.25 / 1; }
  .ns-slide-content { padding: 24px 14px 36px; }
  .ns-slider-arrow { width: 38px; height: 38px; margin-top: -19px; }
  .ns-slider-prev { left: 8px; }
  .ns-slider-next { right: 8px; }
}

.system-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: var(--space-4);
  padding: 7px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-ink);
  font-weight: 700;
  text-decoration: none;
}
.system-back:hover, .system-back:focus-visible {
  border-color: var(--color-accent);
  color: var(--color-accent);
  text-decoration: none;
}
.system-back[hidden] { display: none; }
@media print { .system-back { display: none; } }

.ns-photo-note {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: var(--space-2) var(--space-2) 0;
  margin: 0;
}
.ns-photo-note .form-control {
  width: 100%;
  min-width: 0;
  height: 34px;
  font-size: 0.8rem;
}
.ns-photo-note .btn {
  align-self: flex-start;
}
.ns-photo-note-text {
  margin: 0;
  padding: var(--space-2) var(--space-2) 0;
  font-size: 0.82rem;
}

.ns-wa { position: relative; }
.ns-wa-btn { background: #1f9e50; color: #fff; cursor: pointer; list-style: none; }
.ns-wa-btn::-webkit-details-marker { display: none; }
.ns-wa-btn:hover, .ns-wa[open] .ns-wa-btn { background: #168545; color: #fff; }
.ns-wa-panel {
  position: absolute;
  z-index: 30;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  width: min(360px, calc(100vw - 32px));
  padding: 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 35px rgba(20, 22, 61, .18);
}
.ns-wa-title { font-weight: 800; margin-bottom: 5px; }
.ns-wa-hint { color: var(--color-muted); font-size: .85rem; line-height: 1.6; }
.ns-wa-choice { display: block; margin: 10px 0; cursor: pointer; line-height: 1.5; }
.ns-wa-choice input { margin-inline-end: 5px; }
.ns-wa-panel .form-control { width: 100%; margin: 5px 0 12px; }
.ns-wa-send { width: 100%; background: #1f9e50; color: #fff; }
.ns-wa-send:hover { background: #168545; color: #fff; }
@media (max-width: 767px) {
  .ns-wa-panel { inset-inline-end: auto; inset-inline-start: 0; }
}

/* ===== PART P — «62 - 1 - 13» with what each number is =================== */
.ns-addr {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 2px 10px;
  max-width: 100%;
  unicode-bidi: isolate;
  vertical-align: top;
}
.ns-addr-part {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  max-width: 100%;
  min-width: 0;
  line-height: 1.15;
}
.ns-addr-value { max-width: 100%; font-variant-numeric: tabular-nums; }
/* in a table row the address stays on one line; on a phone the row is a card,
   and a long address wraps inside it */
.main-table .ns-addr { flex-wrap: nowrap; }
@media (max-width: 767px) {
  .main-table .ns-addr { flex-wrap: wrap; }
  .ns-addr-value { white-space: normal; overflow-wrap: break-word; text-align: center; }
}
.ns-addr-label {
  margin-top: 3px;
  font-size: .62rem;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--color-muted);
  white-space: nowrap;
}
.ns-addr-sep { opacity: .45; }
.ns-slide-name .ns-addr-label { color: rgba(255, 255, 255, .78); font-size: .68rem; }

/* ===== PART Q — a city's «نوع الفورم» (categories.php, reference.php) ===== */
.ns-form-style { display: grid; gap: 8px; }
/* specific enough to beat «.page-content .form-horizontal label» */
.page-content .form-horizontal .ns-form-style-choice,
.ns-form-style-choice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  font-weight: 400;
  cursor: pointer;
}
.ns-form-style-choice:has(input:checked) { border-color: var(--color-accent); background: var(--color-accent-soft); }
.ns-form-style-choice input { margin-top: 2px; }
.ns-form-style-choice span { display: flex; flex-direction: column; gap: 2px; font-weight: 600; color: var(--color-ink, #14163d); }
.ns-form-style .asterisk { display: none !important; }
.ns-form-style-badge { font-size: .7rem; vertical-align: middle; }
.ns-inline-form select.form-control { width: auto; }

/* ===== PART R — version and credit at the foot of every page ============= */
.ns-credit {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin: 40px auto 0;
  padding: 14px 16px 18px;
  border-top: 1px solid var(--color-border);
  color: var(--color-muted);
  font-size: .72rem;
  letter-spacing: .01em;
  opacity: .7;
  transition: opacity .25s ease;
}
.ns-credit:hover { opacity: 1; }
.ns-credit-sep { opacity: .5; }
.ns-credit-owner { font-weight: 600; transition: color .25s ease; }
.ns-credit:hover .ns-credit-owner { color: var(--color-ink, #14163d); }
/* the sign-in page: on its dark background, not in a strip under it */
.login-screen + .ns-credit {
  position: relative;
  height: 48px;
  margin: -48px 0 0;
  padding: 0 16px;
  border: 0;
  color: rgba(255, 255, 255, .6);
}
.login-screen + .ns-credit:hover .ns-credit-owner { color: #fff; }
@media print { .ns-credit { display: none; } }

/* «الحقوق والشروط»: the popup from the credit, and legal.php */
.ns-credit-link {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}
.ns-credit-link:hover, .ns-credit-link:focus-visible { color: inherit; text-decoration: none; }
.ns-legal {
  width: min(680px, calc(100vw - 32px));
  max-height: min(82vh, 760px);
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: var(--color-surface);
  color: var(--color-ink, #14163d);
  box-shadow: 0 24px 70px rgba(10, 12, 40, .35);
  overflow: auto;
}
.ns-legal::backdrop { background: rgba(10, 12, 40, .55); backdrop-filter: blur(2px); }
.ns-legal[open] { animation: ns-legal-in .22s ease-out; }
@keyframes ns-legal-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.ns-legal-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
}
.ns-legal-head h2 { margin: 0; font-size: 1.1rem; font-weight: 800; }
.ns-legal-close {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: var(--color-bg, #f3f2ee);
  color: var(--color-ink, #14163d);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}
.ns-legal-close:hover { background: var(--color-accent-soft); color: var(--color-accent); }
.ns-legal-body { padding: 18px 22px 22px; font-size: .9rem; line-height: 1.85; text-align: right; }
.ns-legal-body h3 { margin: 18px 0 6px; font-size: .98rem; font-weight: 800; color: var(--color-navy, #14163d); }
.ns-legal-body p { margin: 0 0 6px; }
.ns-legal-body ul { margin: 4px 0 6px; padding-inline-start: 22px; }
.ns-legal-body li { margin-bottom: 4px; }
.ns-legal-lead { padding: 12px 14px; border-radius: 10px; background: var(--color-bg, #f3f2ee); }
.ns-legal-foot { margin-top: 18px !important; color: var(--color-muted); font-size: .8rem; text-align: center; }
.ns-legal-page { min-height: 100vh; padding: 32px 16px; background: var(--color-bg, #f3f2ee); }
.ns-legal-card {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 8px 24px;
  border-radius: 16px;
  background: var(--color-surface);
  box-shadow: var(--shadow-lift, 0 6px 24px rgba(0, 0, 0, .06));
  text-align: center;
}
.ns-legal-card h1 { margin: 0 0 4px; font-size: 1.4rem; font-weight: 800; }
@media print { .ns-legal { display: none; } }

/* «إضافة طلب»: «من / إلى» side by side */
.ns-range { display: flex; gap: var(--space-2); }
.ns-range .form-control { flex: 1 1 0; min-width: 0; }
#ns-order-matches[aria-busy="true"] { opacity: 0.55; transition: opacity 0.15s; }

/* the lists' «بحث متقدم»: folded under the two boxes until clicked */
.ns-live-search { flex-wrap: wrap; max-width: none; }
.ns-adv { flex: 1 1 100%; }
.ns-adv > summary { list-style: none; cursor: pointer; display: inline-block; }
.ns-adv > summary::-webkit-details-marker { display: none; }
.ns-adv[open] > summary { margin-bottom: var(--space-3); }
.ns-adv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
  gap: var(--space-3);
}
.ns-adv-grid label { display: flex; flex-direction: column; gap: var(--space-1, 4px); margin: 0; font-weight: 600; font-size: 0.88rem; }

/* «سجل العمليات» */
.ns-history td { vertical-align: top; text-align: start; }
.ns-history-old { color: var(--color-muted, #6b7280); text-decoration: line-through; }
.ns-history-new { font-weight: 600; }
.ns-history-card > summary { cursor: pointer; }

/* ===== responsive add forms ================================================
   The add forms (and «إضافة عقار»'s three choices) are not split into
   section cards, so they kept the legacy float grid: col-md-2 next to
   col-md-4, rows that never lined up and half-empty lines on a tablet. They
   get the same aligned grid as the sectioned edit forms — as many equal
   columns as the screen holds, one on a phone. Long fields (notes, photos,
   anything col-md-12) take the whole row; on wide screens the fields that
   were wider (col-md-4 / col-md-6) take two columns. No markup changes. */
.formadd:not([data-ns-sectioned]) {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-4) var(--space-3);
  align-items: start;
  margin: 0;
}
.formadd:not([data-ns-sectioned])::after { display: none; }
.formadd:not([data-ns-sectioned]) > * { grid-column: 1 / -1; }
.formadd:not([data-ns-sectioned]) > .form-group,
.formadd:not([data-ns-sectioned]) > .form-group[class*="col-"] {
  display: flex;
  flex-direction: column;
  gap: 6px;
  grid-column: auto;
  float: none;
  width: auto;
  max-width: none;
  min-width: 0;
  margin: 0;
  padding: 0;
}
.formadd:not([data-ns-sectioned]) > .form-group[hidden] { display: none; }
.formadd:not([data-ns-sectioned]) > .form-group > label { margin: 0; }
.formadd:not([data-ns-sectioned]) .form-control { width: 100%; }
.formadd:not([data-ns-sectioned]) > .form-group.col-md-12,
.formadd:not([data-ns-sectioned]) > .form-group:has(textarea, input[type="file"], img, a[data-lightbox]) {
  grid-column: 1 / -1;
}
@media (min-width: 1100px) {
  .formadd:not([data-ns-sectioned]) > .form-group.col-md-4,
  .formadd:not([data-ns-sectioned]) > .form-group.col-md-6 { grid-column: span 2; }
}
/* the submit row's own Bootstrap offset columns */
.formadd:not([data-ns-sectioned]) > .form-group.col-md-12 > [class*="col-sm-"] {
  float: none;
  width: auto;
  margin: 0;
  padding: 0;
}

/* «سجل العمليات»: the filters as one compact line (it wraps only when the screen is too narrow) */
.ns-logbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-2);
  margin: 0 0 var(--space-4);
}
.ns-logbar label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-ink-soft);
}
.ns-logbar .form-control {
  height: 30px;
  padding: 0 6px;
  font-size: 0.8rem;
  width: auto;
  min-width: 0;
}
.ns-logbar select.form-control { width: 7.5rem; max-width: 7.5rem; }
.ns-logbar input[name="record"] { width: 5.5rem; }
.ns-logbar input[type="date"] { width: 8.5rem; }
.ns-logbar .btn { height: 30px; padding: 0 var(--space-3); font-size: 0.85rem; }

/* «إضافة عقار»: a gap between the three choices and the form they open */
#ns-add-pick { margin-bottom: var(--space-4); }

/* «إضافة طلب»: the matching properties under the whole form, full width */
.ns-order-matches-card { width: 100%; min-width: 0; grid-column: 1 / -1; }
.ns-order-matches-card .table-responsive { width: 100%; max-height: 26rem; overflow: auto; }
.ns-order-matches-card .table-responsive tr:first-child td { position: sticky; top: 0; z-index: 1; background: var(--color-surface); }
.ns-order-matches-card table { width: 100%; }
.ns-order-matches-card td { white-space: nowrap; }

/* a grid column never grows past the screen because of a wide child (the
   dashboard's bar charts pushed its cards off the left edge on a phone) */
.responsive-grid-2col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.responsive-grid-2col > *, .responsive-grid-main-side > * { min-width: 0; }
@media (max-width: 900px) {
  .responsive-grid-2col,
  .responsive-grid-main-side { grid-template-columns: minmax(0, 1fr); }
}

/* «إضافة طلب عميل»: the client, then one card per request */
.ns-order-card { margin-bottom: var(--space-4); }
.ns-order-card > .report-section-title { margin: 0 0 var(--space-3); }
.ns-order-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-3);
  align-items: start;
}
.ns-order-grid > label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  min-width: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-ink-soft);
}
.ns-order-grid > label .form-control { width: 100%; font-weight: 400; }
.ns-order-grid > .ns-wide { grid-column: 1 / -1; }
.ns-order-block-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin-bottom: var(--space-3); }
.ns-order-block-head .report-section-title { margin: 0; }
.ns-block-remove { color: var(--color-danger, #c0392b); }
.ns-block-matches { margin-top: var(--space-3); border-top: 1px solid var(--color-border); padding-top: var(--space-3); }
.ns-block-matches > summary { cursor: pointer; font-weight: 600; }
.ns-block-matches-host { margin-top: var(--space-3); }
.ns-block-matches-host .table-responsive { max-height: 22rem; overflow: auto; }
.ns-block-matches-host .table-responsive tr:first-child td { position: sticky; top: 0; z-index: 1; background: var(--color-surface); }
.ns-order-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); justify-content: space-between; align-items: center; margin-bottom: var(--space-5); }

/* ===== very wide and very large screens =====================================
   On a 2560px or 4K screen the forms spread over the whole width with small
   type, and the eye loses the line. The content keeps a readable width in the
   middle, and from 2200px up everything is drawn larger (zoom keeps every
   proportion; layout widths are measured in the zoomed size). */
.page-content {
  width: 100%;
  max-width: 1760px;
  margin-inline: auto;
}
@media (min-width: 2200px) { html { zoom: 1.2; } }
@media (min-width: 3000px) { html { zoom: 1.5; } }

/* the lists' two search boxes: each label beside its own box, the advanced
   search under them — on a laptop as on a phone */
.ns-live-search {
  display: grid;
  grid-template-columns: auto minmax(6.5rem, 11rem) auto minmax(0, 1fr);
  align-items: center;
  gap: var(--space-2) var(--space-3);
}
.ns-live-search .ns-live-code { flex: none; }
.ns-live-search > .ns-adv,
.ns-live-search > noscript { grid-column: 1 / -1; }
@media (max-width: 600px) {
  .ns-live-search { grid-template-columns: auto minmax(0, 1fr); }
}

/* «الشعار والعلامة المائية» */
.ns-brand-logo { max-height: 34px; max-width: 160px; object-fit: contain; }
.top-nav-brand { margin-inline-end: var(--space-3); }
.ns-login-logo { display: block; max-height: 90px; max-width: 220px; margin: 0 auto var(--space-3); object-fit: contain; }
.ns-share-logo { display: block; max-height: 64px; max-width: 200px; margin-bottom: var(--space-3); object-fit: contain; }
.ns-brand-current { margin-bottom: var(--space-3); padding: var(--space-3); border: 1px dashed var(--color-border); border-radius: var(--radius-md); background: repeating-conic-gradient(#eee 0% 25%, #fff 0% 50%) 50% / 16px 16px; display: inline-block; }
.ns-brand-current img { display: block; max-height: 120px; max-width: 320px; }
.ns-sub-title { font-size: 0.9rem; font-weight: 700; margin: var(--space-4) 0 var(--space-2); }
.ns-checks { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); }
.ns-check { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; margin: 0; }
.ns-check input { width: 18px; height: 18px; }
.ns-brand-preview { margin-top: var(--space-4); }
.ns-brand-preview img { display: block; max-width: 100%; height: auto; border-radius: var(--radius-md); border: 1px solid var(--color-border); }
.ns-order-grid input[type="range"] { width: 100%; }
.ns-order-grid > label.ns-check { flex-direction: row; align-items: center; align-self: end; }


/* ===== the number of photos next to a property's code (partials/photocount.ejs) == */
.ns-photo-count {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-inline-start: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(20, 22, 61, 0.07);
  color: var(--color-navy);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}
.ns-photo-count .fa {
  font-size: 0.72rem;
  color: var(--color-muted);
}
.ns-list-id .ns-photo-count {
  display: flex;
  width: max-content;
  margin: 3px 0 0;
}

/* ===== «تفاصيل الطلب» in the orders list: up to three lines, all on hover == */
.ns-order-details-cell {
  min-width: 220px;
  max-width: 420px;
  text-align: start;
}
.ns-order-details-cell > div {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-line;
  line-height: 1.5;
}

/* ===== «المرحلة» / «المجموعة» (partials/stagegroup.ejs): the field not in use is
   out of sight even where .form-control or a section grid sets a display == */
[data-sg-stage-wrap][hidden],
[data-sg-stagetext-wrap][hidden],
[data-sg-group-select][hidden],
[data-sg-group-text][hidden] {
  display: none !important;
}

/* «من / إلى» number boxes on the stages list (reference.ejs) */
.ns-inline-form .ns-num-narrow {
  width: 7.5rem;
  min-width: 0;
  flex: 0 0 auto;
}

/* ===== «النسخ الاحتياطي» (backup.ejs) ===================================== */
.ns-backup-status {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}
.ns-backup-status .card p { margin: var(--space-2) 0 0; }
.ns-backup-error {
  color: var(--color-accent);
  font-size: 0.86rem;
  word-break: break-word;
}
.ns-backup-now {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin: calc(-1 * var(--space-2)) 0 var(--space-5);
}
.ns-backup-now .help-block { margin: 0; }
.ns-backup-smtp,
.ns-backup-advanced {
  margin-top: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: var(--space-3) var(--space-4);
}
.ns-backup-smtp > summary,
.ns-backup-advanced > summary {
  cursor: pointer;
  font-weight: 700;
}
.ns-backup-steps { margin: var(--space-3) 0 0; padding-inline-start: 1.4em; line-height: 1.9; }
.ns-backup-schedule [hidden] { display: none !important; }
.ns-backup-details { max-width: 420px; text-align: start; }

/* ===== «الفورمات والخانات الإضافية» (forms-builder.ejs, lib/customfields.js) == */
.ns-cf-places {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: var(--space-3);
}
.ns-cf-place {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  opacity: 0.7;
}
.ns-cf-place.is-on { opacity: 1; border-color: var(--color-navy); background: rgba(20, 22, 61, 0.03); }
.ns-cf-preview-pick { display: inline-flex; align-items: center; gap: var(--space-2); margin: 0; font-weight: 600; }
.ns-cf-preview-pick select { width: auto; min-width: 16rem; }
.ns-cf-preview {
  max-height: 75vh;
  overflow: auto;
  border: 1px dashed var(--color-border);
  border-radius: 10px;
  padding: var(--space-3);
  background: var(--color-surface, #fff);
}
.ns-cf-preview .container { width: auto; max-width: none; padding: 0; }
.ns-cf-new {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
  border-radius: 8px;
  background: rgba(237, 28, 36, 0.06);
}
.ns-cf-where div + div { margin-top: 2px; }
[data-when-type][hidden] { display: none !important; }

/* ===== rows in alternating shades, so the eye follows a line across ======== */
.main-table.table > tbody > tr:nth-child(even):not(:first-child) > td {
  background: rgba(20, 22, 61, 0.05);
}
.main-table.table > tbody > tr:not(:first-child):hover > td,
.main-table.table > tbody > tr.ns-row-link:not(:first-child):hover > td {
  background: rgba(20, 22, 61, 0.1);
}
/* phones and tablets show each row as a card (see the 991px block above) */
@media (max-width: 991px) {
  .main-table.table > tbody > tr:nth-child(even):not(:first-child) {
    background: #f1f2f6;
  }
  .main-table.table > tbody > tr:nth-child(even):not(:first-child) > td {
    background: transparent;
  }
}

/* ===== «قائمة اختيار متعدد» (lib/customfields.js): a dropdown of tick boxes == */
.ns-multi { position: relative; }
.ns-multi > summary {
  list-style: none;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-inline-end: 2rem;
}
.ns-multi > summary::-webkit-details-marker { display: none; }
.ns-multi > summary::after {
  content: '▾';
  position: absolute;
  inset-inline-end: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-muted);
}
.ns-multi-list {
  position: absolute;
  z-index: 30;
  inset-inline: 0;
  top: calc(100% + 4px);
  max-height: 260px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: var(--space-3);
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  box-shadow: 0 10px 24px rgba(20, 22, 61, 0.14);
}
.ns-multi-list .ns-check { font-weight: 500; }
.ns-cf-title { display: block; font-weight: 600; margin-bottom: 6px; }

/* ===== «تم البيع» on the order's page (orders/view.ejs) ==================== */
.ns-sold-facts { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); margin-top: var(--space-2); }
.ns-sold-note { margin-top: var(--space-2); white-space: pre-wrap; }

/* ===== a list row's buttons wrap inside their cell instead of overflowing == */
.ns-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-start;
  min-width: 170px;
  max-width: 250px;
}
.ns-row-actions form { display: contents; }
.ns-row-actions .btn { white-space: nowrap; }
.main-table td.ns-num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ===== «سجل المتابعات» and «كاليندر المتابعات» (orders/followups.ejs, calendar.ejs) == */
.ns-followup-form {
  display: grid;
  grid-template-columns: minmax(0, 160px) minmax(0, 180px) minmax(0, 1fr) minmax(0, 160px) auto;
  gap: var(--space-3);
  align-items: end;
  margin-bottom: var(--space-4);
}
.ns-followup-form label { display: flex; flex-direction: column; gap: 4px; margin: 0; font-weight: 600; font-size: 0.86rem; }
@media (max-width: 991px) { .ns-followup-form { grid-template-columns: repeat(2, minmax(0, 1fr)); } .ns-followup-note { grid-column: 1 / -1; } }
.ns-followup-text { white-space: pre-wrap; max-width: 420px; text-align: start; }

.ns-cal-due { margin-bottom: var(--space-4); }
.ns-cal-duelist { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 6px var(--space-4); }
.ns-cal-duelist li { padding: 6px 10px; border-radius: 8px; border-inline-start: 4px solid var(--color-warning, #d97706); background: rgba(217, 119, 6, 0.06); }
.ns-cal-duelist li.is-late { border-color: var(--color-accent); background: rgba(237, 28, 36, 0.06); }
.ns-cal-when { font-size: 0.8rem; font-weight: 700; }
.ns-cal-duelist li.is-late .ns-cal-when { color: var(--color-accent); }
.ns-cal-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin: var(--space-4) 0 var(--space-2); }
.ns-cal-title { margin: 0 var(--space-3); font-size: 1.25rem; }
.ns-cal-filter { display: flex; gap: 6px; margin-inline-start: auto; }
.ns-cal-filter select { width: auto; min-width: 12rem; }
.ns-cal { border: 1px solid var(--color-border); border-radius: 12px; overflow: hidden; background: var(--color-surface, #fff); }
.ns-cal-head, .ns-cal-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.ns-cal-head > div { padding: 8px; font-weight: 700; font-size: 0.85rem; text-align: center; background: var(--color-bg-alt); border-bottom: 1px solid var(--color-border); }
.ns-cal-day { min-height: 110px; padding: 6px; border-inline-end: 1px solid var(--color-border); border-bottom: 1px solid var(--color-border); display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ns-cal-week .ns-cal-day:last-child { border-inline-end: 0; }
.ns-cal-day.is-out { background: rgba(20, 22, 61, 0.03); }
.ns-cal-day.is-out .ns-cal-date { color: var(--color-muted); }
.ns-cal-day.is-today { background: rgba(237, 28, 36, 0.05); }
.ns-cal-day.is-today .ns-cal-date { background: var(--color-accent); color: #fff; }
.ns-cal-date { align-self: flex-start; min-width: 26px; padding: 1px 6px; border-radius: 999px; font-weight: 700; font-size: 0.82rem; text-align: center; }
.ns-cal-item { display: block; font-size: 0.76rem; line-height: 1.35; padding: 2px 6px; border-radius: 6px; text-decoration: none; overflow-wrap: anywhere; }
.ns-cal-item.is-done { background: rgba(22, 163, 74, 0.1); color: #166534; }
.ns-cal-item.is-due { background: rgba(37, 99, 235, 0.1); color: #1e40af; }
.ns-cal-item.is-late { background: rgba(237, 28, 36, 0.12); color: #b91c1c; font-weight: 700; }
.ns-cal-item:hover { filter: brightness(0.95); text-decoration: underline; }
@media (max-width: 760px) {
  .ns-cal-head { display: none; }
  .ns-cal-week { grid-template-columns: 1fr; }
  .ns-cal-day { min-height: 0; border-inline-end: 0; }
  .ns-cal-day:not(.is-today):empty, .ns-cal-day.is-out { display: none; }
}

/* ===== «سجل الدفعات» (commissions/paymentsledger.ejs, partials/planpayments.ejs) ===== */
.ns-pay-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--space-3); margin-bottom: var(--space-4); }
.ns-pay-box { border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: var(--space-3); }
.ns-pay-box .row-between { margin-bottom: var(--space-2); }
.ns-pay-figures { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); font-size: 0.86rem; }
.ns-pay-figures strong { display: block; font-size: 1rem; font-variant-numeric: tabular-nums; }
.ns-pay-void td { opacity: .6; text-decoration: line-through; }
.ns-pay-void td .ns-result-meta { text-decoration: none; white-space: normal; }
@media (max-width: 767px) { .ns-pay-void-form { min-width: 0; flex-wrap: wrap; } .ns-followup-text { max-width: 100%; white-space: normal; overflow-wrap: anywhere; } }
.ns-pay-void-form { display: flex; gap: var(--space-1); align-items: center; min-width: 200px; }
.ns-pay-states .badge { display: inline-block; margin: 1px 0; white-space: nowrap; }
/* a label-and-value table keeps its first row on a phone: it is data, not a header */
@media (max-width: 767px) {
  .main-table.table[data-ns-no-head] > tbody > tr:first-child { display: block; }
}

/* ===== the status buttons on a commission's page (commissions/view.ejs) ===== */
.ns-status-head { display: flex; align-items: baseline; gap: var(--space-3); margin-bottom: var(--space-3); }
.ns-status-bar { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.ns-status-btn { min-width: 7.5rem; }
.ns-status-btn.is-current { cursor: default; pointer-events: none; }
.ns-status-btn[disabled] { opacity: .45; cursor: not-allowed; }

/* ===== «تم التعاقد»: its two choices (orders/contractbutton.ejs, view.ejs) ===== */
.ns-contract-menu { position: relative; display: inline-block; }
.ns-contract-menu > summary { list-style: none; cursor: pointer; }
.ns-contract-menu > summary::-webkit-details-marker { display: none; }
.ns-contract-choices { position: absolute; inset-inline-start: 0; top: calc(100% + 4px); z-index: 30; display: flex; flex-direction: column; gap: var(--space-1); min-width: 10rem; padding: var(--space-2); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); box-shadow: var(--shadow-subtle); }
.ns-contract-choices .btn { width: 100%; white-space: nowrap; }
.ns-contract-type { display: flex; flex-wrap: wrap; gap: var(--space-3); border: 0; padding: 0; margin: 0 0 var(--space-4); }
.ns-contract-type legend { font-weight: 700; margin-bottom: var(--space-2); }
.ns-contract-option { display: inline-flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-4); border: 1px solid var(--color-border); border-radius: var(--radius-md); cursor: pointer; font-weight: 600; }
.ns-contract-option:has(input:checked) { border-color: var(--color-accent); background: var(--color-surface-alt, rgba(0, 0, 0, .03)); }
/* the salesperson filter of «جميع الطلبات» */
.ns-member-filter { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin: var(--space-3) 0; }
.ns-member-filter label { font-weight: 700; margin: 0; }
.ns-member-filter select { width: auto; min-width: 14rem; max-width: 100%; }
@media (max-width: 767px) {
  /* on a phone the two choices open under the button, inside the screen */
  .ns-contract-choices { position: static; margin-top: var(--space-1); box-shadow: none; }
}

/* ===== «النسخة التجريبية» (lib/demo.js) ===== */
.ns-demo-strip { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--space-2) var(--space-4); padding: 6px var(--space-4); background: #fff4d6; color: #6b4b00; border-bottom: 1px solid #f0d58a; font-size: 0.88rem; text-align: center; }
.ns-demo-reset { display: inline; margin: 0; }
.ns-demo-reset .btn-link { padding: 0; font-size: 0.88rem; font-weight: 700; color: #6b4b00; text-decoration: underline; }
.login-demo-name { font-size: 1.6rem; font-weight: 800; letter-spacing: .5px; }
.login-demo { display: flex; flex-direction: column; gap: var(--space-3); margin-bottom: var(--space-4); padding-bottom: var(--space-4); border-bottom: 1px solid var(--color-border); }
.login-demo-note { margin: 0; text-align: center; font-weight: 600; }
.login-demo-form { display: flex; flex-direction: column; gap: 4px; margin: 0; }
.login-demo-form small { text-align: center; color: var(--color-muted); direction: ltr; unicode-bidi: plaintext; }
.login-demo-or { margin: 0; text-align: center; color: var(--color-muted); font-size: 0.85rem; }
