/* =========================================================
   Rent Prog — light RTL admin shell
   ========================================================= */

:root {
  --bg: #EEF2F6;
  --surface: #ffffff;
  --border: #E1E6EE;
  --border-strong: #C9D0DC;
  --text: #1F2933;
  --muted: #6B7280;
  --primary: #2F6F5E;
  --primary-hover: #255A4C;
  --primary-soft: #E8F3EF;
  --accent: #6B8F71;
  --danger: #C0392B;
  --danger-soft: #FDECEA;
  --warning: #B7791F;
  --warning-soft: #FFF8E7;
  --info: #2B6CB0;
  --info-soft: #EBF4FF;
  --sidebar-width: 240px;
  --sidebar-bg: #142824;
  --sidebar-bg-mid: #17302B;
  --sidebar-label: #A8C4BA;
  --sidebar-accent: #7EB89A;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-soft: 0 1px 2px rgba(31, 41, 51, 0.04);
  --font: "Tajawal", "Noto Sans Arabic", Tahoma, sans-serif;
  --panel-pad: 1.25rem 1.4rem;
  --panel-gap: 1.15rem;
  --card-pad: 1.1rem 1.2rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 15px;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  min-height: 100vh;
  line-height: 1.55;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  color: var(--primary-hover);
}

img {
  max-width: 100%;
}

/* Western digits / LTR numeric & date fields (page stays RTL for Arabic text).
   direction:ltr + unicode-bidi:isolate keeps Western digit order readable;
   text-align:right pins values to the same side as Arabic labels/headers. */
.num,
td.num,
th.num,
.stat-card__value,
.info-item__value.num,
input[type="date"],
input[type="number"],
input[type="tel"],
input[inputmode="decimal"],
input[inputmode="numeric"],
input.num,
input.flatpickr-input,
input.flatpickr-alt-input,
.flatpickr-calendar {
  font-variant-numeric: lining-nums tabular-nums;
  font-feature-settings: "tnum" 1;
  direction: ltr;
  unicode-bidi: isolate;
}

.num,
td.num,
th.num,
.info-item__value.num,
input[type="date"],
input[type="number"],
input[type="tel"],
input[inputmode="decimal"],
input[inputmode="numeric"],
input.num,
input.flatpickr-input,
input.flatpickr-alt-input {
  text-align: right;
}

/* Dashboard stat values stay centered inside .stat-card */
.stat-card__value {
  text-align: center;
}

/* Flatpickr — match light admin theme; English calendar UI */
.flatpickr-calendar {
  direction: ltr;
  font-family: var(--font);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(31, 41, 51, 0.12);
}

.flatpickr-months .flatpickr-month,
.flatpickr-current-month .flatpickr-monthDropdown-months,
.flatpickr-current-month input.cur-year,
span.flatpickr-weekday,
.flatpickr-day {
  color: var(--text);
  font-weight: 500;
}

.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange,
.flatpickr-day.selected:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.flatpickr-day.today {
  border-color: var(--primary);
}

.flatpickr-day:hover {
  background: var(--primary-soft);
  border-color: var(--primary-soft);
}

input.flatpickr-alt-input {
  width: 100%;
}

/* ----- Layout ----- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar-backdrop {
  display: none;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: #F3F7F5;
  position: fixed;
  inset: 0 0 0 auto;
  padding: 0;
  display: flex;
  flex-direction: column;
  z-index: 40;
  overflow: hidden;
  border-inline-end: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar__head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 0.85rem 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.sidebar__brand {
  display: block;
  flex: 1;
  min-width: 0;
  padding: 0.35rem 0.55rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: #fff;
  letter-spacing: 0.01em;
  line-height: 1.35;
}

.sidebar__brand:hover {
  color: #fff;
}

.sidebar__close {
  display: none;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
}

.sidebar__close:hover {
  background: rgba(255, 255, 255, 0.16);
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
  padding: 0.95rem 0.7rem 1rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.nav-group + .nav-group {
  margin-top: 0.15rem;
}

.nav-group__label {
  margin: 0 0 0.35rem;
  padding: 0 0.7rem;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.03em;
  color: var(--sidebar-label);
  text-transform: none;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.88);
  font-size: 0.9rem;
  position: relative;
  transition: background 0.12s ease, color 0.12s ease;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.nav-link.is-active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-weight: 600;
}

.nav-link.is-active::before {
  content: "";
  position: absolute;
  top: 0.4rem;
  bottom: 0.4rem;
  inset-inline-start: 0;
  width: 3px;
  border-start-start-radius: 0;
  border-end-start-radius: 0;
  border-start-end-radius: 3px;
  border-end-end-radius: 3px;
  background: var(--sidebar-accent);
}

.nav-link__icon {
  width: 1.2rem;
  height: 1.2rem;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.9;
}

.nav-link__icon svg {
  width: 1.1rem;
  height: 1.1rem;
  display: block;
}

.sidebar__footer {
  flex-shrink: 0;
  padding: 0.75rem 0.65rem 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.12);
}

.sidebar__user {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.35rem 0.7rem 0.55rem;
}

.sidebar__user-name {
  font-size: 0.9rem;
  font-weight: 650;
  color: #fff;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar__user-role {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.55);
}

.nav-link--logout {
  margin-top: 0.15rem;
  color: rgba(255, 255, 255, 0.8);
}

.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 2.35rem;
  height: 2.35rem;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
}

.sidebar-toggle:hover {
  background: var(--primary-soft);
  border-color: #B7D4C8;
  color: var(--primary);
}

.app-main {
  flex: 1;
  margin-right: var(--sidebar-width);
  padding: 1.5rem 1.75rem 2.5rem;
  min-width: 0;
}

.app-main--standalone {
  margin-right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(47, 111, 94, 0.12), transparent 45%),
    radial-gradient(ellipse at 90% 80%, rgba(107, 143, 113, 0.1), transparent 40%),
    var(--bg);
}

/* ----- Page header ----- */
.page-header {
  margin-bottom: 1.35rem;
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.65rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.breadcrumbs a {
  color: var(--muted);
}

.breadcrumbs a:hover {
  color: var(--primary);
}

.breadcrumbs__sep {
  opacity: 0.5;
}

.page-header__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
}

.page-title {
  margin: 0;
  flex: 1;
  min-width: 12rem;
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.page-header__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* ----- Panels / cards ----- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--panel-pad);
  margin-bottom: var(--panel-gap);
  box-shadow: var(--shadow-soft);
}

.panel__title {
  margin: 0 0 1rem;
  font-size: 1.05rem;
  font-weight: 650;
  color: var(--text);
  padding-right: 0.65rem;
  border-right: 3px solid var(--primary);
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.panel__head .panel__title {
  margin: 0;
}

.panel__link {
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
}

.panel + .panel {
  margin-top: 0;
}

/* ----- Dashboard ----- */
.dash-welcome {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  padding: 1.1rem 1.25rem;
  background:
    linear-gradient(135deg, rgba(47, 111, 94, 0.08), transparent 55%),
    var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.dash-welcome__greeting {
  margin: 0 0 0.25rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

.dash-welcome__date {
  margin: 0;
  font-size: 0.92rem;
  color: var(--muted);
}

.dash-welcome__meta {
  margin: 0 0 0.2rem;
  font-size: 0.92rem;
  color: var(--text);
  font-weight: 500;
}

.dash-welcome__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0.55rem;
}

/* Featured Documents CTA — co-primary with welcome quick actions */
.dash-docs-cta {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0.1rem;
  min-width: 9.5rem;
  padding: 0.55rem 1.05rem;
  border-radius: var(--radius-sm);
  border: 1px solid #2A5F52;
  background:
    linear-gradient(135deg, #23443C 0%, #2F6F5E 58%, #3A7D6A 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(27, 53, 48, 0.22);
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
  text-decoration: none;
  line-height: 1.25;
}

.dash-docs-cta:hover {
  color: #fff;
  background:
    linear-gradient(135deg, #1B3530 0%, #255A4C 58%, #2F6F5E 100%);
  box-shadow: 0 4px 14px rgba(27, 53, 48, 0.28);
  transform: translateY(-1px);
}

.dash-docs-cta__label {
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.dash-docs-cta__sub {
  font-size: 0.72rem;
  font-weight: 500;
  color: rgba(232, 243, 239, 0.88);
  white-space: nowrap;
}

/* Owner YTD income chip — calm surface next to docs CTA */
.dash-income-cta {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0.05rem;
  min-width: 9.5rem;
  padding: 0.55rem 1.05rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  line-height: 1.25;
  box-shadow: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

a.dash-income-cta:hover {
  color: var(--text);
  border-color: var(--primary);
  background: var(--primary-soft);
}

.dash-income-cta__label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
}

.dash-income-cta__value {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text);
}

.dash-income-cta__sub {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}

.dash-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.dash-kpi {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 1.05rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
  min-height: 6.5rem;
}

.dash-kpi:hover {
  border-color: var(--primary);
  color: var(--text);
  box-shadow: 0 2px 10px rgba(47, 111, 94, 0.1);
  transform: translateY(-1px);
}

.dash-kpi__label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
}

.dash-kpi__value {
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
  text-align: right;
}

.dash-kpi__meta {
  margin-top: auto;
  font-size: 0.82rem;
  color: var(--muted);
}

.dash-kpi--danger .dash-kpi__value { color: var(--danger); }
.dash-kpi--warning .dash-kpi__value { color: var(--warning); }
.dash-kpi--info .dash-kpi__value { color: var(--info); }
.dash-kpi--docs .dash-kpi__value { color: #5B6B7C; }
.dash-kpi--primary .dash-kpi__value { color: var(--primary); }
.dash-kpi--calm .dash-kpi__value { color: var(--muted); }
.dash-kpi--calm {
  border-color: var(--border);
  opacity: 0.92;
}

.page-actions-more {
  position: relative;
  display: inline-block;
}

.page-actions-more > summary {
  list-style: none;
  cursor: pointer;
}

.page-actions-more > summary::-webkit-details-marker {
  display: none;
}

.page-actions-more__menu {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 9rem;
  padding: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 20px rgba(31, 41, 51, 0.12);
}

.panel--collapsible {
  padding-top: 0.85rem;
}

.panel--collapsible > summary.panel__title {
  cursor: pointer;
  list-style: none;
  margin-bottom: 0.75rem;
}

.panel--collapsible > summary.panel__title::-webkit-details-marker {
  display: none;
}

.panel--collapsible > summary.panel__title::after {
  content: "▾";
  margin-right: 0.4rem;
  color: var(--muted);
  font-size: 0.85em;
}

.panel--collapsible[open] > summary.panel__title::after {
  content: "▴";
}

.form-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.form-steps__item {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 600;
}

.form-steps__item:hover {
  color: var(--primary-hover);
}

.skip-link {
  position: absolute;
  right: 1rem;
  top: -3rem;
  z-index: 100;
  padding: 0.5rem 0.85rem;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.skip-link:focus {
  top: 0.75rem;
  color: #fff;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

a:focus:not(:focus-visible),
button:focus:not(:focus-visible) {
  outline: none;
}

.dash-shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-bottom: 1.25rem;
}

.dash-shortcuts__link {
  display: inline-flex;
  align-items: center;
  padding: 0.55rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  box-shadow: var(--shadow-soft);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.dash-shortcuts__link:hover {
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(47, 111, 94, 0.1);
}

.dash-cell-primary {
  display: block;
  font-weight: 600;
}

.dash-cell-secondary {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.15rem;
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-table--overdue .od-col-amount .dash-cell-secondary,
.data-table--compact-dash .badge-warning + .dash-cell-secondary {
  max-width: none;
  white-space: normal;
}

.dash-inventory {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.65rem;
  margin-bottom: 1.15rem;
  padding: 0.65rem 0.75rem;
  background: transparent;
}

.dash-inventory__item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.65rem 0.8rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.55);
}

.dash-inventory__label {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
}

.dash-inventory__value {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  text-align: right;
}

table.data-table--compact-dash {
  min-width: 0;
}

table.data-table--compact-dash th,
table.data-table--compact-dash td {
  padding: 0.55rem 0.65rem;
  font-size: 0.86rem;
  white-space: normal;
}

/* Stacked action links: same start/end edges when two buttons wrap.
   Inner flex lives on a wrapper when present; td itself stays table-cell. */
table.data-table td.dash-actions-stack {
  text-align: start;
  vertical-align: middle;
  min-width: 7.25rem;
  display: table-cell;
}

table.data-table td.dash-actions-stack.actions-inline {
  display: table-cell;
}

.dash-actions-stack.actions-inline {
  /* legacy: class on td — use column flow via inline-flex children instead */
  flex-direction: unset;
  flex-wrap: unset;
}

table.data-table td.dash-actions-stack > .btn,
table.data-table td.dash-actions-stack > a.btn,
table.data-table td.dash-actions-stack > form {
  display: flex;
  width: 100%;
  box-sizing: border-box;
  margin: 0.15rem 0;
  white-space: nowrap;
  justify-content: center;
}

.dash-actions-stack.actions-inline .btn {
  width: 100%;
  white-space: nowrap;
  justify-content: center;
}

/* Stat cards — OK on dashboard */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.2rem;
  text-align: center;
  box-shadow: var(--shadow-soft);
}

.stat-card__label {
  margin: 0 0 0.45rem;
  font-size: 0.92rem;
  color: var(--muted);
  font-weight: 500;
}

.stat-card__value {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary);
}

/* ----- Tables ----- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

table.data-table th,
table.data-table td {
  padding: 0.75rem 0.85rem;
  text-align: right;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-size: 0.92rem;
  vertical-align: middle;
}

/* عقود قاربت الانتهاء — وضوح عمود المستأجر والحالة */
table.data-table.data-table--lease-expiry {
  min-width: 640px;
}

table.data-table.data-table--lease-expiry .le-col-tenant {
  white-space: normal;
  min-width: 9rem;
  max-width: 16rem;
  line-height: 1.35;
  overflow-wrap: break-word;
  word-break: break-word;
}

table.data-table.data-table--lease-expiry .le-col-days {
  white-space: nowrap;
}

table.data-table.data-table--lease-expiry .le-status {
  display: inline-block;
  margin-inline-end: 0.3rem;
  padding: 0.08rem 0.4rem;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.3;
}

table.data-table.data-table--lease-expiry .le-status--expired {
  background: #fde8e8;
  color: #9b1c1c;
}

table.data-table.data-table--lease-expiry .le-status--soon {
  background: #fff6e5;
  color: #8a6116;
}

table.data-table.data-table--lease-expiry .le-status--today {
  background: var(--primary-soft);
  color: var(--primary);
}

table.data-table.data-table--lease-expiry .le-days-unit {
  margin-inline-start: 0.15rem;
  color: var(--muted);
  font-size: 0.85rem;
}

table.data-table.data-table--lease-expiry .le-col-unit {
  max-width: 10rem;
  white-space: normal;
}

/* تسوية المالك — منع تداخل المستأجر/الوصف مع المبلغ */
table.data-table.data-table--owner-settlement {
  min-width: 640px;
}

table.data-table.data-table--owner-settlement .os-col-tenant,
table.data-table.data-table--owner-settlement .os-col-property,
table.data-table.data-table--owner-settlement .os-col-desc {
  white-space: normal;
  line-height: 1.35;
  overflow-wrap: break-word;
  word-break: break-word;
}

table.data-table.data-table--owner-settlement .os-col-tenant {
  min-width: 8.5rem;
  max-width: 14rem;
}

table.data-table.data-table--owner-settlement .os-col-amount {
  white-space: nowrap;
  font-variant-numeric: lining-nums tabular-nums;
  font-feature-settings: "tnum" 1;
  direction: ltr;
  unicode-bidi: isolate;
  font-weight: 650;
  min-width: 6.5rem;
}

.os-section-title {
  margin: 1rem 0 0.5rem;
  font-size: 1rem;
}

/* مصفوفات الأشهر (دخل عام للمالك) — خلايا أضيق للطباعة والعرض */
table.data-table--compact {
  min-width: 960px;
}
table.data-table--compact th,
table.data-table--compact td {
  padding: 0.4rem 0.35rem;
  font-size: 0.8rem;
}
table.data-table--omi {
  table-layout: fixed;
  width: 100%;
  min-width: 0;
}
table.data-table--omi th,
table.data-table--omi td {
  padding: 0.28rem 0.16rem;
  font-size: 0.75rem;
  vertical-align: middle;
  box-sizing: border-box;
}
table.data-table--omi th.num,
table.data-table--omi td.num {
  text-align: right;
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
  font-variant-numeric: lining-nums tabular-nums;
  font-feature-settings: "tnum" 1;
  direction: ltr;
  unicode-bidi: isolate;
}
/* Month cells: fixed-width digits so decimals stack across rows */
table.data-table--omi th.omi-m,
table.data-table--omi td.omi-m {
  padding: 0.22rem 0.1rem;
  font-size: 0.68rem;
  letter-spacing: 0;
  text-align: right;
  font-variant-numeric: lining-nums tabular-nums;
  font-feature-settings: "tnum" 1;
  font-family: ui-monospace, "Cascadia Mono", "Segoe UI Mono", "Roboto Mono", Menlo, Consolas, monospace;
  direction: ltr;
  unicode-bidi: isolate;
  border-inline-start: 0.3pt solid #c5cdd6;
}
table.data-table--omi thead th.omi-m {
  background: #e8eef4;
  text-align: center;
  vertical-align: middle;
}
/* Stronger rule between month block and unit total (units table only) */
table.data-table--omi--units th:nth-child(14),
table.data-table--omi--units td:nth-child(14) {
  border-inline-start: 1pt solid #9aa5b1;
}
table.data-table--omi th:first-child,
table.data-table--omi td:first-child {
  text-align: right;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Summary: name + 12 months only (KPIs live in top cards) */
.omi-report table.data-table--omi--summary col.omi-col-name {
  width: 14%;
}
.omi-report table.data-table--omi--summary col.omi-col-m {
  width: 7.15%;
}
.omi-report table.data-table--omi--units col.omi-col-name {
  width: 12%;
}
.omi-report table.data-table--omi--units col.omi-col-m {
  width: 6.3%;
}
.omi-report table.data-table--omi--units col.omi-col-tot {
  width: 12.4%;
}

/* Action button columns stay centered */
table.data-table td.actions-inline,
table.data-table th.actions-inline {
  text-align: center;
}

table.data-table th {
  background: #F1F4F7;
  color: #374151;
  font-weight: 650;
}

table.data-table tbody tr:hover td {
  background: #FAFBFC;
}

table.data-table tbody tr:last-child td {
  border-bottom: none;
}

table.data-table input[type="text"],
table.data-table input[type="number"],
table.data-table input[type="date"] {
  width: 100%;
  min-width: 5rem;
  margin: 0;
}

/* ----- Forms ----- */
label {
  display: block;
  margin-top: 0.9rem;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
  color: #4B5563;
  font-weight: 500;
}

label:first-child {
  margin-top: 0;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="tel"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea {
  min-height: 110px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 111, 94, 0.15);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem 1.1rem;
}

.form-row--3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1.35rem;
}

.unit-add-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.65rem;
  align-items: end;
}

.unit-add-row label {
  margin-top: 0;
}

.units-checklist {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin: 0.35rem 0 0.85rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border, #d7ddd9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.55);
  max-height: 220px;
  overflow: auto;
}

.units-checklist__item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.55rem;
  align-items: center;
  margin: 0;
  padding: 0.35rem 0.25rem;
  cursor: pointer;
}

.units-checklist__item input {
  width: auto;
  margin: 0;
}

.units-checklist__name {
  font-weight: 600;
}

.units-checklist__meta {
  font-size: 0.85rem;
  opacity: 0.8;
}

.muted {
  color: var(--muted, #6b7280);
  font-size: 0.9rem;
}

.duration-display {
  min-height: 2.6rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border, #d7ddd9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.55);
}

.duration-display__primary {
  font-weight: 600;
  line-height: 1.35;
}

.duration-display__secondary {
  margin-top: 0.15rem;
  font-size: 0.82rem;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem 1.25rem;
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.info-item__label {
  font-size: 0.82rem;
  color: var(--muted);
}

.info-item__value {
  font-size: 0.98rem;
  color: var(--text);
  font-weight: 500;
  min-width: 0;
}

/* ----- Buttons ----- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.55rem 0.95rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--primary);
  color: #fff;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  line-height: 1.3;
}

.btn:hover {
  background: var(--primary-hover);
  color: #fff;
}

.btn-secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-secondary:hover {
  background: #F3F5F7;
  color: var(--text);
}

.btn-back {
  background: #fff;
  color: var(--text);
  border-color: var(--border-strong);
  padding: 0.5rem 0.85rem;
}

.btn-back:hover {
  background: var(--primary-soft);
  border-color: #B7D4C8;
  color: var(--primary);
}

.btn-warning {
  background: #C9852D;
  color: #fff;
}

.btn-warning:hover {
  background: #A66C1F;
  color: #fff;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #9B2C20;
  color: #fff;
}

.btn-info {
  background: var(--info);
  color: #fff;
}

.btn-info:hover {
  background: #1A4F8A;
  color: #fff;
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.82rem;
}

.btn-block {
  width: 100%;
}

.actions-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
  align-items: center;
}

/*
 * Never make a <td> a flex container — that breaks table-cell layout and
 * makes row border lines look crooked next to the actions column.
 * Keep the cell as table-cell; lay out buttons as inline-flex siblings.
 */
table.data-table td.actions-inline:not(.dash-actions-stack),
table.data-table th.actions-inline:not(.dash-actions-stack) {
  display: table-cell;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
}

table.data-table td.actions-inline:not(.dash-actions-stack) > .btn,
table.data-table td.actions-inline:not(.dash-actions-stack) > a.btn,
table.data-table td.actions-inline:not(.dash-actions-stack) > form {
  display: inline-flex;
  vertical-align: middle;
  margin-block: 0.1rem;
  margin-inline: 0.15rem;
}

table.data-table td.actions-inline:not(.dash-actions-stack) > form {
  margin: 0.1rem 0.15rem;
}

/* ----- Alerts / badges ----- */
.flash-stack {
  margin-bottom: 0.25rem;
}

.alert {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  border: 1px solid transparent;
  font-size: 0.92rem;
}

.alert--dismissible {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.alert__text {
  flex: 1;
  min-width: 0;
}

.alert__close {
  flex: 0 0 auto;
  margin: -0.25rem -0.35rem -0.25rem 0;
  padding: 0.15rem 0.45rem;
  border: none;
  background: transparent;
  color: inherit;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.7;
  border-radius: 4px;
}

.alert__close:hover {
  opacity: 1;
  background: rgba(31, 41, 51, 0.06);
}

.alert-success {
  background: #EDF8F1;
  border-color: #B7E0C5;
  color: #1F6B3A;
}

.alert-error {
  background: var(--danger-soft);
  border-color: #F5C6CB;
  color: #721C24;
}

.alert-info {
  background: var(--info-soft);
  border-color: #BEE3F8;
  color: #1A4F8A;
}

.alert-warning {
  background: var(--warning-soft);
  border-color: #F6E05E;
  color: #744210;
}

.badge {
  display: inline-block;
  padding: 0.25rem 0.55rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
}

.badge-danger {
  background: var(--danger-soft);
  color: #9B2C20;
}

.badge-warning {
  background: var(--warning-soft);
  color: #8A5A10;
}

.badge-success {
  background: #EDF8F1;
  color: #1F6B3A;
}

.badge-info {
  background: var(--info-soft);
  color: #1A4F8A;
}

.badge-secondary {
  background: #EDF2F7;
  color: #3D4F5F;
}

.empty-state {
  text-align: center;
  padding: 1.5rem;
  color: var(--muted);
  font-size: 0.95rem;
}

/* ----- Auth ----- */
.auth-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.75rem;
  box-shadow: var(--shadow-soft);
}

.auth-card__brand {
  text-align: center;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0 0 0.35rem;
}

.auth-card__title {
  text-align: center;
  margin: 0 0 1.4rem;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
}

.auth-footer {
  text-align: center;
  margin-top: 1.1rem;
  font-size: 0.85rem;
  color: var(--muted);
}

/* ----- Print docs ----- */
@media print {
  .sidebar,
  .sidebar-toggle,
  .sidebar-backdrop,
  .page-header,
  .no-print {
    display: none !important;
  }

  .app-main {
    margin: 0;
    padding: 0;
  }

  .panel {
    border: none;
    box-shadow: none;
    padding: 0;
  }

  .print-details .panel__title {
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
  }

  .print-details .info-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem 1rem;
  }

  .print-details .info-item__label {
    font-size: 0.75rem;
  }

  .print-details .info-item__value {
    font-size: 0.92rem;
  }
}

/* ----- Responsive ----- */
@media (max-width: 1100px) {
  .stats-grid,
  .dash-kpi-grid,
  .dash-inventory {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* screen only — print page width is often <900px and must keep 2-col info grids */
@media screen and (max-width: 900px) {
  .sidebar-toggle {
    display: inline-flex;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(31, 41, 51, 0.4);
    z-index: 45;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  body.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  body.sidebar-open .sidebar-backdrop[hidden] {
    display: block;
  }

  .sidebar {
    width: min(280px, 86vw);
    transform: translateX(105%);
    transition: transform 0.22s ease;
    z-index: 50;
    box-shadow: -8px 0 28px rgba(31, 41, 51, 0.18);
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar__close {
    display: inline-flex;
  }

  .app-main {
    margin-right: 0;
    padding: 1.1rem;
  }

  body.sidebar-open {
    overflow: hidden;
  }

  .form-row,
  .form-row--3,
  .info-grid {
    grid-template-columns: 1fr;
  }

  .unit-add-row {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 560px) {
  .stats-grid,
  .dash-kpi-grid,
  .dash-inventory {
    grid-template-columns: 1fr;
  }

  .page-title {
    font-size: 1.3rem;
  }

  .hub-grid,
  .hub-grid--large {
    grid-template-columns: 1fr;
  }

  .dash-welcome {
    padding: 1rem;
  }

  th.col-secondary,
  td.col-secondary {
    display: none;
  }

  .dash-welcome__greeting {
    font-size: 1.1rem;
  }

  .dash-welcome__actions {
    width: 100%;
  }

  .dash-docs-cta,
  .dash-income-cta {
    flex: 1 1 100%;
    min-width: 0;
    align-items: stretch;
  }

  .dash-docs-cta__sub,
  .dash-income-cta__sub {
    white-space: normal;
  }
}

/* ----- Hub cards / report tabs ----- */
.hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.85rem;
}

.hub-grid--large {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.hub-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: var(--card-pad);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  box-shadow: var(--shadow-soft);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.hub-card:hover {
  border-color: var(--primary);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(47, 111, 94, 0.08);
}

.hub-card--accent {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.hub-card__title {
  font-weight: 650;
  font-size: 1.02rem;
  color: var(--primary);
}

.hub-card__desc {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.45;
}

.hub-card__meta {
  margin-top: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.hub-card__badges {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
}

/* ----- Reports hub catalog ----- */
.reports-hub__note {
  margin: 0 0 0.85rem;
  font-size: 0.92rem;
}

.reports-hub__section {
  margin-bottom: 1.35rem;
}

.reports-hub__section-title {
  margin: 0 0 0.25rem;
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--text);
}

.reports-hub__section-desc {
  margin: 0 0 0.85rem;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.45;
}

/* اختصارات نصية + قائمة مجمّعة */
.reports-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.75rem;
  margin: 0 0 1.25rem;
  padding: 0 0 0.85rem;
  border-bottom: 1px solid var(--border);
}

.reports-quick__link {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
  padding: 0.2rem 0;
  border-bottom: 2px solid transparent;
}

.reports-quick__link:hover {
  color: var(--primary);
  border-bottom-color: rgba(47, 111, 94, 0.35);
}

.reports-quick__link--accent {
  font-weight: 700;
}

.reports-quick__link.is-active {
  border-bottom-color: var(--primary);
}

.reports-group {
  margin: 0 0 1.35rem;
}

.reports-group__title {
  margin: 0 0 0.5rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
}

.reports-group__hint {
  margin: -0.15rem 0 0.55rem;
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.4;
}

.reports-group__list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.report-row {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.72rem 0.95rem;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  border-inline-start: 3px solid transparent;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.report-row:last-child {
  border-bottom: none;
}

.report-row:hover {
  background: var(--bg);
  color: var(--text);
}

.report-row.is-active {
  background: var(--primary-soft);
  border-inline-start-color: var(--primary);
}

.report-row--static {
  cursor: default;
}

.report-row__title {
  font-weight: 650;
  font-size: 0.98rem;
  color: var(--primary);
}

.report-row__desc {
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.4;
}

.reports-hub__picker {
  margin: 0 0 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.reports-hub__picker-summary {
  cursor: pointer;
  list-style: none;
  padding: 0.7rem 1rem;
  font-weight: 650;
  font-size: 0.95rem;
  color: var(--primary);
  user-select: none;
}

.reports-hub__picker-summary::-webkit-details-marker {
  display: none;
}

.reports-hub__picker-summary::before {
  content: "◂ ";
  font-size: 0.85em;
  opacity: 0.7;
}

.reports-hub__picker[open] .reports-hub__picker-summary::before {
  content: "▾ ";
}

.reports-hub__picker-body {
  padding: 0 1rem 1rem;
  border-top: 1px solid var(--border);
}

.reports-hub__picker-body .reports-quick {
  margin-top: 0.85rem;
}

.reports-hub__browse {
  margin-bottom: 0.5rem;
}

.reports-scenarios {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.85rem;
}

.reports-scenario {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 1.15rem 1.2rem;
  min-height: 7.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  box-shadow: var(--shadow-soft);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.reports-scenario:hover {
  border-color: var(--primary);
  color: var(--text);
  box-shadow: 0 2px 10px rgba(47, 111, 94, 0.1);
}

.reports-scenario--accent {
  border-color: var(--primary);
  background: linear-gradient(160deg, var(--primary-soft) 0%, var(--surface) 70%);
}

.reports-scenario.is-active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(47, 111, 94, 0.18);
}

.reports-scenario__title {
  font-weight: 700;
  font-size: 1.12rem;
  color: var(--primary);
}

.reports-scenario__desc {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.45;
}

.reports-catalog {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.85rem;
}

.report-card {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: var(--card-pad);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  box-shadow: var(--shadow-soft);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.report-card:hover {
  border-color: var(--primary);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(47, 111, 94, 0.08);
}

.report-card.is-active {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 2px rgba(47, 111, 94, 0.16);
}

.report-card--pack {
  border-style: dashed;
}

.report-card--messaging {
  border-color: #C9D0DC;
  background: #F7FAFC;
}

.report-card--static {
  cursor: default;
}

.report-card--static:hover {
  border-color: #C9D0DC;
  box-shadow: var(--shadow-soft);
}

.report-card__title {
  font-weight: 650;
  font-size: 1.02rem;
  color: var(--primary);
}

.report-card__desc {
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.45;
  flex: 1;
}

.report-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.25rem;
}

.report-tag {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 650;
  line-height: 1.35;
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
}

.report-card.is-active .report-tag {
  background: var(--surface);
  border-color: rgba(47, 111, 94, 0.25);
  color: var(--primary);
}

.reports-hub__filter-desc,
.reports-hub__pack-desc {
  margin: 0 0 0.85rem;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.45;
}

.reports-hub__pack--focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(47, 111, 94, 0.12);
}

.reports-hub__result-head {
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
}

.reports-hub__result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-inline-start: auto;
}

.reports-hub__day19 p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

@media (max-width: 640px) {
  .reports-scenarios,
  .reports-catalog {
    grid-template-columns: 1fr;
  }

  .reports-hub__result-actions {
    margin-inline-start: 0;
    width: 100%;
  }

  .reports-hub__result-actions .btn {
    flex: 1 1 auto;
    text-align: center;
  }
}

.doc-badge {
  display: inline-block;
  padding: 0.12rem 0.45rem;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 650;
  line-height: 1.35;
  white-space: nowrap;
}

.doc-badge--expired {
  background: var(--danger-soft);
  color: #9B2C20;
}

.doc-badge--soon {
  background: var(--warning-soft);
  color: #8A5A10;
}

.doc-row--expired td {
  background: var(--danger-soft);
}

.doc-row--soon td {
  background: var(--warning-soft);
}

table.data-table td.doc-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.doc-expiry--expired,
.doc-expiry--soon {
  font-weight: 600;
}

.doc-expiry--expired {
  color: #9B2C20;
}

.doc-expiry--soon {
  color: #8A5A10;
}

.doc-expiry-label {
  display: inline-block;
  margin-inline-start: 0.35rem;
  padding: 0.05rem 0.4rem;
  border-radius: 5px;
  font-size: 0.78rem;
  font-weight: 650;
  vertical-align: middle;
}

.doc-expiry--expired .doc-expiry-label {
  background: rgba(192, 57, 43, 0.12);
}

.doc-expiry--soon .doc-expiry-label {
  background: rgba(183, 121, 31, 0.14);
}

.property-scope-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 1rem;
  padding: 0.65rem 0.85rem;
  background: var(--surface-muted, rgba(0, 0, 0, 0.03));
  border: 1px solid var(--border);
  border-radius: var(--radius, 8px);
}

.property-scope-bar__label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-muted, #5c6570);
}

.property-scope-bar__select {
  min-width: 12rem;
  max-width: 100%;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface, #fff);
  font: inherit;
}

.list-search-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 1rem;
}

.list-search-bar__label {
  font-size: 0.88rem;
  color: var(--muted);
  font-weight: 600;
}

.list-search-bar__input {
  flex: 1 1 12rem;
  min-width: 10rem;
  max-width: 22rem;
  margin: 0;
}

.empty-state-block {
  text-align: center;
  padding: 1.25rem 0.75rem;
}

.empty-state-block__title {
  margin: 0 0 0.35rem;
  font-weight: 650;
  color: var(--text);
}

.empty-state-block__text {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
}

table.data-table tbody tr.table-group-row td {
  background: var(--surface-muted, #f0f2f5);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  white-space: normal;
  padding-top: 0.55rem;
  padding-bottom: 0.55rem;
}

table.data-table tbody tr.table-group-row:hover td {
  background: var(--surface-muted, #f0f2f5);
}

.table-group-row__title {
  margin-left: 0.5rem;
}

.table-group-row__meta {
  display: inline-block;
  margin-inline-start: 0.35rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.06);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted, #5c6570);
}

.table-group-row__link {
  margin-inline-start: 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--accent, #1a5f7a);
  text-decoration: none;
}

.table-group-row__link:hover {
  text-decoration: underline;
}

.property-ops-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 0.85rem;
}

.docs-jump {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.docs-jump a {
  color: var(--primary);
  font-weight: 550;
}

.docs-jump a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

#docs-main,
#docs-other,
#docs-upload {
  scroll-margin-top: 1rem;
}

.tabs-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.tabs-bar__link {
  padding: 0.45rem 0.95rem;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 550;
}

.tabs-bar__link:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.tabs-bar__link.is-active {
  background: var(--primary);
  color: #fff;
}

.tabs-bar__link.is-active:hover {
  color: #fff;
}

.tabs-bar__count {
  display: inline-block;
  margin-inline-start: 0.35rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  font-size: 0.78rem;
  background: rgba(0, 0, 0, 0.08);
  color: inherit;
}

.tabs-bar__link.is-active .tabs-bar__count {
  background: rgba(255, 255, 255, 0.22);
}

/* Owner monthly income — preview (screen) */
.omi-report .omi-stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 1.15rem;
  gap: 0.85rem;
}

.omi-report .omi-meta-note {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 400;
}

.omi-report .omi-summary-note {
  margin: -0.25rem 0 0.55rem;
  font-size: 0.85rem;
}

.omi-report .omi-section-title {
  margin: 0 0 0.55rem;
  font-size: 1.05rem;
  font-weight: 650;
  color: var(--text);
  padding-right: 0.65rem;
  border-right: 3px solid var(--primary);
}

/* Owner monthly income — CSS bar chart (screen + print-friendly) */
.omi-summary-page {
  margin-bottom: 1.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid #E4E7EB;
}

.omi-tables-page {
  margin-bottom: 1.5rem;
}

.omi-tables-page > .omi-section-title:first-child {
  margin-top: 0;
}

.omi-tables-page > .omi-section-title:not(:first-child) {
  margin-top: 1.25rem;
}

.omi-tables-page .omi-section-title + .table-wrap,
.omi-tables-page .omi-summary-note + .table-wrap {
  margin-bottom: 0;
}

.omi-month-chart {
  margin: 0 0 1.15rem;
}

.omi-chart {
  display: flex;
  align-items: stretch;
  gap: 0.4rem;
  height: 200px;
  margin: 0;
  padding: 0.85rem 0.65rem 0.45rem;
  background: #f7faf9;
  border: 1px solid #E4E7EB;
  border-radius: 8px;
}

.omi-chart__col {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  height: 100%;
}

.omi-chart__bar-wrap {
  flex: 1 1 auto;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-height: 0;
}

.omi-chart__bar {
  width: 58%;
  max-width: 26px;
  height: 0;
  background: var(--primary);
  border-radius: 4px 4px 0 0;
}

.omi-chart__bar.is-filled {
  min-height: 3px;
}

.omi-chart__label {
  flex: 0 0 auto;
  margin-top: 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted, #52606D);
  line-height: 1;
}

.omi-chart__amount {
  flex: 0 0 auto;
  margin-top: 0.22rem;
  font-size: 0.68rem;
  font-weight: 600;
  color: #243B53;
  line-height: 1.15;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  font-variant-numeric: lining-nums tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* Horizontal bars — potential income by property */
.omi-prop-chart {
  margin: 0 0 1rem;
}

.omi-hbar-chart {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin: 0;
  padding: 0.75rem 0.85rem;
  background: #f7faf9;
  border: 1px solid #E4E7EB;
  border-radius: 8px;
}

.omi-hbar {
  display: grid;
  grid-template-columns: minmax(4.5rem, 10rem) 1fr auto;
  gap: 0.55rem;
  align-items: center;
}

.omi-hbar__name {
  font-size: 0.88rem;
  font-weight: 600;
  color: #243B53;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.omi-hbar__track {
  height: 12px;
  background: #e8efec;
  border-radius: 4px;
  overflow: hidden;
  min-width: 0;
}

.omi-hbar__fill {
  height: 100%;
  width: 0;
  background: var(--primary, #2F6F5E);
  border-radius: 4px;
}

.omi-hbar__fill.is-filled {
  min-width: 3px;
}

.omi-hbar__value {
  font-size: 0.82rem;
  font-weight: 650;
  color: #243B53;
  white-space: nowrap;
  font-variant-numeric: lining-nums tabular-nums;
  font-feature-settings: "tnum" 1;
  min-width: 4.5rem;
  text-align: left;
}

.omi-occupancy {
  margin: 0 0 0.25rem;
  padding: 0.55rem 0.75rem;
  background: #f7faf9;
  border: 1px solid #E4E7EB;
  border-radius: 8px;
}

.omi-occupancy__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
  color: #52606D;
}

.omi-occupancy__track {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  background: #e8efec;
}

.omi-occupancy__seg--rented {
  background: var(--primary, #2F6F5E);
}

.omi-occupancy__seg--vacant {
  background: #e53e3e;
}

.omi-report table.data-table--omi--props {
  table-layout: auto;
  width: 100%;
}

.omi-report table.data-table--omi--props th.num,
.omi-report table.data-table--omi--props td.num {
  white-space: nowrap;
}

.omi-report tr.omi-totals-row td {
  font-weight: 700;
  background: #f5f7fa;
}

.omi-report tr.omi-row-vacant td {
  background: #fdeaea;
}

.omi-report .omi-vacant-tag {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: #9b1c1c;
  background: #fbd5d5;
  border-radius: 3px;
  vertical-align: middle;
}

@media (max-width: 720px) {
  .omi-report .omi-stats {
    grid-template-columns: 1fr;
  }

  .omi-chart {
    height: 170px;
    gap: 0.25rem;
    padding: 0.65rem 0.4rem 0.3rem;
  }

  .omi-chart__label {
    font-size: 0.7rem;
  }

  .omi-chart__amount {
    font-size: 0.58rem;
  }

  .omi-hbar {
    grid-template-columns: minmax(3.5rem, 7rem) 1fr auto;
    gap: 0.4rem;
  }

  .omi-hbar__name {
    font-size: 0.8rem;
  }

  .omi-hbar__value {
    font-size: 0.75rem;
    min-width: 3.5rem;
  }
}

/* Building annual income (accrual) report */
.bai-report .omi-section-title {
  margin: 1.25rem 0 0.65rem;
  font-size: 1.05rem;
}

.bai-report .table-wrap {
  overflow-x: hidden;
}

.bai-report table.data-table {
  min-width: 0;
}

.bai-report table.data-table--bai {
  table-layout: fixed;
  width: 100%;
  min-width: 0;
}

.bai-report table.data-table--bai th,
.bai-report table.data-table--bai td {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  padding: 0.22rem 0.18rem;
  font-size: 0.72rem;
  line-height: 1.25;
  vertical-align: top;
}

.bai-report table.data-table--bai th.num,
.bai-report table.data-table--bai td.num {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.bai-report table.data-table--bai col.bai-col-tenant { width: 14%; }
.bai-report table.data-table--bai col.bai-col-unit { width: 9%; }
.bai-report table.data-table--bai col.bai-col-contract { width: 7%; }
.bai-report table.data-table--bai col.bai-col-date { width: 8%; }
.bai-report table.data-table--bai col.bai-col-days { width: 5%; }
.bai-report table.data-table--bai col.bai-col-pct { width: 4%; }
.bai-report table.data-table--bai col.bai-col-money { width: 9%; }
.bai-report table.data-table--bai col.bai-col-note { width: 6%; }

/* Hide basic/service — keep subtotal / vat / total only */
.bai-report .bai-col-extra {
  display: none;
}

.bai-report table.data-table--bai th.bai-col-note,
.bai-report table.data-table--bai td.bai-col-note {
  width: 6%;
  max-width: 4.5rem;
  font-size: 0.68rem;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: break-word;
}

.bai-report tr.bai-row-shared td {
  background: #fff8eb;
}

.bai-report tr.bai-tenant-subtotal td {
  font-weight: 600;
  background: #f5f7fa;
  color: var(--muted, #52606d);
}

.bai-property-block {
  margin-top: 1.5rem;
}

/* ----- System setup wizard / readiness ----- */
.setup-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.setup-steps__item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
}

.setup-steps__item:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.setup-steps__item.is-active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.setup-steps__item.is-done {
  border-color: #B7E0C5;
  color: #1F6B3A;
}

.setup-steps__num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.45rem;
  height: 1.45rem;
  border-radius: 50%;
  background: #EEF1F4;
  font-size: 0.8rem;
}

.setup-steps__item.is-active .setup-steps__num {
  background: var(--primary);
  color: #fff;
}

.setup-checklist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.setup-checklist__item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
}

.setup-checklist__item.is-ok {
  border-color: #B7E0C5;
  background: #EDF8F1;
}

.setup-checklist__item.is-pending {
  border-color: #F0D9A8;
  background: #FFF8EB;
}

.setup-checklist__mark {
  flex: 0 0 auto;
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}

.setup-checklist__item.is-ok .setup-checklist__mark {
  background: #1F6B3A;
  color: #fff;
}

.setup-checklist__item.is-pending .setup-checklist__mark {
  background: #C9852D;
  color: #fff;
}

.setup-checklist__hint {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 400;
}

.panel--danger {
  border-color: #F5C6CB;
  background: linear-gradient(180deg, #FFF5F5 0%, var(--surface) 48%);
}

.panel--danger .panel__title {
  border-right-color: var(--danger);
  color: #9B2C20;
}

.setup-danger-form input[type="text"] {
  max-width: 280px;
}

/* Searchable select (combobox) — used for tenant pickers on contract forms */
.searchable-select {
  position: relative;
  width: 100%;
}

.searchable-select__native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.searchable-select__control {
  position: relative;
  display: flex;
  align-items: center;
}

.searchable-select__input {
  width: 100%;
  padding: 0.65rem 0.8rem;
  padding-left: 2.2rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.searchable-select__input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 111, 94, 0.15);
}

.searchable-select__input[aria-invalid="true"] {
  border-color: var(--danger);
}

.searchable-select__clear {
  position: absolute;
  left: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.7rem;
  height: 1.7rem;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.searchable-select__clear:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.searchable-select__list {
  position: absolute;
  z-index: 40;
  inset-inline: 0;
  top: calc(100% + 4px);
  max-height: 240px;
  margin: 0;
  padding: 0.3rem;
  list-style: none;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(31, 41, 51, 0.12);
}

.searchable-select__option {
  padding: 0.55rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
}

.searchable-select__option:hover,
.searchable-select__option.is-active {
  background: var(--primary-soft);
  color: var(--primary-hover);
}

.searchable-select__option.is-selected {
  font-weight: 600;
}

.searchable-select__option.is-recent::after {
  content: " · أخير";
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--muted);
}

.searchable-select__empty {
  padding: 0.65rem 0.7rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.searchable-select.is-open .searchable-select__input {
  border-color: var(--primary);
}
