/* Site Header — RTL / Vazirmatn */
:root {
  --surface: var(--tone-surface, #FFFFFF);
  --border: #E4E2D8;
  --border-strong: #D3D1C4;
  --ink: #1C2B24;
  --ink-soft: #45524A;
  --muted: #7C8479;
  --accent: #0F5C4F;
  --accent-strong: #0B4B40;
  --accent-soft: #E4EFEC;
  --danger: #B23A3A;
  --danger-soft: #F8EAE9;
  --phx-header-h: 68px;
}

body {
  margin: 0;
  padding: 0;
}

body:has(.phx-header) .wrap {
  padding: 16px;
  padding-top: 0;
  box-sizing: border-box;
}

body:has(.phx-header) .shell {
  max-width: 1180px;
  margin-inline: auto;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

body:has(.landing-hero) .wrap,
body:has(.login-container) .wrap {
  padding-top: 0 !important;
}

body:has(.phx-header) {
  padding-top: var(--phx-header-h);
}

/* ── Header shell ── */
.phx-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 300;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-family: "Vazirmatn", "Tahoma", sans-serif;
}

.phx-header-inner {
  position: relative;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 8px 0 20px;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.phx-header-brand-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.phx-header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
  margin-inline-end: 0;
}

.phx-header-brand .phx-header-clock-stack,
.phx-header-brand .phx-header-clock {
  margin: 0 2px;
}

.phx-header-clock-stack {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 3px;
  min-width: 0;
}

.phx-header-brand-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.phx-header-brand-icon svg {
  width: 18px;
  height: 18px;
}

.phx-header-brand-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}

/* ── Clock ── */
.phx-header-clock {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 10px;
  background: var(--bg);
  flex-shrink: 0;
}

.phx-header-clock-icon {
  width: 16px;
  height: 16px;
  color: var(--muted);
  flex-shrink: 0;
}

.phx-header-clock-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.phx-clock-time {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
  min-width: 7.5ch;
  text-align: left;
}

.phx-clock-date {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.3;
  white-space: nowrap;
}

/* ── Main nav (desktop) ── */
.phx-header-center {
  flex: 1;
  display: flex;
  justify-content: center;
  min-width: 0;
  padding: 0 24px;
}

.phx-main-nav {
  width: 100%;
  display: flex;
  justify-content: center;
}

.phx-nav-items {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: nowrap;
}

.phx-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  text-decoration: none;
  border-radius: 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.phx-nav-link:hover {
  background: #F5F4EE;
  color: var(--ink);
}

.phx-nav-link.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

/* CTA متمایز: افزودن ساختمان — بعد از مدیریت، کوچک‌تر با آیکون + */
.phx-nav-link--add-building {
  margin-inline-start: 4px;
  padding: 5px 10px;
  gap: 4px;
  border-radius: 999px;
  background: #0F766E;
  color: #ECFDF8;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  box-shadow: 0 1px 2px rgba(15, 118, 110, 0.28);
}

.phx-nav-add-building-icon {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.phx-nav-link--add-building:hover {
  background: #0D9488;
  color: #FFFFFF;
}

.phx-nav-link--add-building.is-active {
  background: #115E59;
  color: #FFFFFF;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

/* Dropdown */
.phx-nav-dropdown {
  position: relative;
}

.phx-nav-dropdown-btn {
  outline: none;
}

.phx-nav-dropdown-chevron {
  width: 14px;
  height: 14px;
  transition: transform 0.15s ease;
}

.phx-nav-dropdown.is-active .phx-nav-dropdown-btn {
  background: var(--accent-soft);
  color: var(--accent);
}

.phx-nav-dropdown.is-open .phx-nav-dropdown-chevron {
  transform: rotate(180deg);
}

.phx-nav-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 190px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(28, 43, 36, 0.1);
  padding: 6px;
  z-index: 30;
}

.phx-nav-dropdown.is-open .phx-nav-dropdown-menu {
  display: block;
}

.phx-nav-dropdown-item {
  display: block;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  text-decoration: none;
  border-radius: 8px;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.phx-nav-dropdown-item:hover,
.phx-nav-dropdown-item.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ── Right actions ── */
.phx-header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.phx-header-actions-main {
  display: flex;
  align-items: center;
  gap: 14px;
}

.phx-icon-btn {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  padding: 0;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  flex-shrink: 0;
  font: inherit;
  appearance: none;
  -webkit-appearance: none;
}

.phx-icon-btn svg {
  width: 18px;
  height: 18px;
}

.phx-icon-btn:hover {
  background: #F5F4EE;
  color: var(--ink);
}

.phx-header-logout:hover {
  background: var(--danger-soft);
  border-color: #F0D4D2;
  color: var(--danger);
}

.phx-notif-btn.has-notif {
  color: var(--ink);
  border-color: #F0D4D2;
  background: #FFF7F6;
}

/* رنگ زنگوله = حالت نمایش فعلی، تا سه حالت از هم جدا دیده شوند */
body[data-ui-mode="simple"] .phx-notif-btn{
  color: #0B4B40;
  background: #E4EFEC;
  border-color: #8FBFB4;
}
body[data-ui-mode="simple"] .phx-notif-btn:hover,
body[data-ui-mode="simple"] .phx-notif-btn.has-notif{
  color: #08382F;
  background: #D5E8E3;
  border-color: #0F5C4F;
}
body[data-ui-mode="medium"] .phx-notif-btn{
  color: #9A3412;
  background: #FFF4E8;
  border-color: #F0B27A;
}
body[data-ui-mode="medium"] .phx-notif-btn:hover,
body[data-ui-mode="medium"] .phx-notif-btn.has-notif{
  color: #7C2D12;
  background: #FFE7D1;
  border-color: #C2410C;
}
body[data-ui-mode="advanced"] .phx-notif-btn{
  color: #1E3A8A;
  background: #E8F0FE;
  border-color: #93B4F5;
}
body[data-ui-mode="advanced"] .phx-notif-btn:hover,
body[data-ui-mode="advanced"] .phx-notif-btn.has-notif{
  color: #1E3A8A;
  background: #D9E6FD;
  border-color: #1D4ED8;
}

.phx-notif-wrap {
  position: relative;
}

.phx-notif-scrim {
  position: fixed;
  inset: 0;
  z-index: 290;
  background: rgba(28, 43, 36, 0);
  border: 0;
  padding: 0;
  margin: 0;
  cursor: default;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s linear, background-color 0.2s ease;
}

.phx-notif-scrim.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  background: rgba(28, 43, 36, 0.22);
}

@media (min-width: 981px) {
  .phx-notif-scrim {
    display: none !important;
  }
}

.phx-notif-badge {
  position: absolute;
  top: -4px;
  left: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: #DC2626;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--surface);
  line-height: 1;
  box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.45);
  animation: phx-notif-pulse 1.8s ease-out infinite;
  z-index: 2;
}

.phx-notif-badge[hidden] {
  display: none !important;
}

.phx-notif-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: min(340px, calc(100vw - 24px));
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(28, 43, 36, 0.14);
  z-index: 310;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-8px) scale(0.96);
  transform-origin: top left;
  transition:
    opacity 0.2s ease,
    transform 0.22s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0.22s linear;
  will-change: opacity, transform;
}

.phx-notif-panel.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.phx-notif-panel[hidden] {
  display: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .phx-notif-panel {
    transition: none;
    transform: none;
  }

  .phx-notif-scrim {
    transition: none;
  }

  .phx-notif-row {
    transition: background-color 0.15s ease;
  }

  .phx-notif-row.is-leaving {
    transform: none;
    max-height: none;
  }
}

.phx-notif-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: #FAFAF7;
}

.phx-notif-panel-head strong {
  font-size: 14px;
  color: var(--ink);
}

.phx-notif-clear-all {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 6px;
  white-space: nowrap;
}

.phx-notif-clear-all:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.phx-notif-clear-all[hidden] {
  display: none !important;
}

.phx-notif-panel-list {
  max-height: 320px;
  overflow: auto;
}

.phx-notif-row {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  border-bottom: 1px solid #F0EEE6;
  transition: background-color 0.15s ease, opacity 0.18s ease, transform 0.18s ease, max-height 0.2s ease;
  max-height: 220px;
  overflow: hidden;
}

.phx-notif-row:last-child {
  border-bottom: none;
}

.phx-notif-row:hover {
  background: #F7F6F1;
}

.phx-notif-row.is-leaving {
  opacity: 0;
  transform: translateX(12px);
  max-height: 0;
  border-bottom-color: transparent;
  pointer-events: none;
}

.phx-notif-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
  padding: 12px 6px 12px 14px;
  text-decoration: none;
  color: var(--ink);
}

.phx-notif-item:hover {
  color: var(--ink);
}

.phx-notif-item-tag {
  align-self: flex-start;
  font-size: 11px;
  font-weight: 700;
  color: #1d4ed8;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  padding: 1px 8px;
}

.phx-notif-item-title {
  font-size: 13px;
  font-weight: 700;
}

.phx-notif-item-body {
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.5;
}

.phx-notif-dismiss {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  margin: 10px 8px 0 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.phx-notif-dismiss:hover {
  background: #fee2e2;
  color: #b91c1c;
}

.phx-notif-dismiss:focus-visible {
  outline: 2px solid #fca5a5;
  outline-offset: 1px;
}

.phx-notif-dismiss svg {
  width: 16px;
  height: 16px;
  display: block;
}

.phx-notif-empty {
  padding: 22px 14px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.phx-join-popup-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.phx-join-popup-backdrop[hidden] {
  display: none !important;
}

.phx-join-popup {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 16px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
  padding: 20px;
}

.phx-join-popup h3 {
  margin: 0 0 8px;
  font-size: 1.1rem;
  color: #0f172a;
}

.phx-join-popup p {
  margin: 0 0 16px;
  color: #475569;
  line-height: 1.7;
  font-size: 0.95rem;
}

.phx-join-popup-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.phx-join-popup-actions .btn-primary,
.phx-join-popup-actions .btn-secondary {
  appearance: none;
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.phx-join-popup-actions .btn-primary {
  background: #0F5C4F;
  color: #fff;
}

.phx-join-popup-actions .btn-secondary {
  background: #f1f5f9;
  color: #334155;
}

@keyframes phx-notif-pulse {
  0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.45); }
  70% { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
  100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .phx-notif-badge { animation: none; }
}

.phx-header-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-right: 12px;
  border-right: 1px solid var(--border);
}

.phx-header-user-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.phx-header-name-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
}

.phx-header-identity {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  min-width: 0;
  max-width: 220px;
}

.phx-header-username {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  width: 100%;
  text-align: start;
}

.phx-header-subrow {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
}

.phx-header-mobile {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--ink-soft, #94a3b8);
  opacity: 0.85;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  text-align: start;
  font-variant-numeric: tabular-nums;
  user-select: text;
}

.phx-header-name-row .phx-header-badge {
  margin-top: 2px;
}

.phx-header-badge {
  display: inline-block;
  flex-shrink: 0;
  padding: 1px 7px;
  border-radius: 100px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 500;
}

.phx-header-profile-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  padding: 2px 8px 2px 7px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent, #0f766e) 35%, #cbd5e1);
  background: color-mix(in srgb, var(--accent, #0f766e) 10%, #fff);
  color: var(--accent, #0f766e);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.15s ease;
}

.phx-header-profile-btn svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.phx-header-profile-btn:hover {
  background: color-mix(in srgb, var(--accent, #0f766e) 18%, #fff);
  border-color: var(--accent, #0f766e);
  box-shadow: 0 3px 8px rgba(15, 118, 110, 0.16);
  transform: translateY(-1px);
}

.phx-header-profile-btn:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.phx-header-profile-btn.is-active {
  background: var(--accent, #0f766e);
  border-color: var(--accent, #0f766e);
  color: #fff;
  box-shadow: 0 3px 8px rgba(15, 118, 110, 0.22);
}

.phx-header-profile-btn:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent, #0f766e) 55%, transparent);
  outline-offset: 2px;
}

html.theme-dark .phx-header-profile-btn {
  background: color-mix(in srgb, var(--accent, #14b8a6) 16%, transparent);
  border-color: color-mix(in srgb, var(--accent, #14b8a6) 45%, rgba(255,255,255,.2));
  color: #5eead4;
  box-shadow: none;
}

html.theme-dark .phx-header-profile-btn:hover {
  background: color-mix(in srgb, var(--accent, #14b8a6) 26%, transparent);
  border-color: #14b8a6;
}

html.theme-dark .phx-header-profile-btn.is-active {
  background: #0f766e;
  border-color: #0f766e;
  color: #fff;
}

.phx-header-page-title {
  display: block;
  font-size: 9px;
  font-weight: 600;
  color: var(--muted, #7C8479);
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  padding: 0 2px;
  opacity: 0.9;
  letter-spacing: 0;
}

.phx-header-page-title--solo {
  font-size: 10px;
  max-width: 120px;
  align-self: center;
}

.phx-mobile-menu-btn {
  display: none;
}

/* ── Mobile sidebar ── */
.phx-sidebar-overlay,
.phx-sidebar {
  display: none;
}

.phx-sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 43, 36, 0.45);
  z-index: 280;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  touch-action: none;
}

.phx-sidebar-overlay.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.phx-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: min(280px, 86vw);
  height: 100vh;
  height: 100dvh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 32px rgba(28, 43, 36, 0.12);
  z-index: 290;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  flex-direction: column;
  pointer-events: none;
}

.phx-sidebar.is-open {
  transform: translateX(0);
  pointer-events: auto;
}

.phx-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.phx-sidebar-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.phx-sidebar-close {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.phx-sidebar-close svg {
  width: 18px;
  height: 18px;
}

.phx-sidebar-close:hover {
  background: #F5F4EE;
  color: var(--ink);
}

.phx-sidebar-content {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 0 16px;
  -webkit-overflow-scrolling: touch;
}

.phx-sidebar-link {
  display: block;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease;
  border-right: 3px solid transparent;
}

.phx-sidebar-link:hover,
.phx-sidebar-link.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

.phx-sidebar-link.is-active {
  border-right-color: var(--accent);
}

.phx-sidebar-link--add-building {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 10px 14px 4px;
  padding: 9px 12px;
  border-radius: 10px;
  border-right: none;
  background: #0F766E;
  color: #ECFDF8;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.phx-sidebar-link--add-building .phx-nav-add-building-icon {
  width: 13px;
  height: 13px;
}

.phx-sidebar-link--add-building:hover,
.phx-sidebar-link--add-building.is-active {
  background: #0D9488;
  color: #FFFFFF;
  border-right-color: transparent;
}

.phx-sidebar-link--logout:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.phx-sidebar-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  padding: 14px 18px 6px;
  margin-top: 4px;
}

body.phx-sidebar-open {
  overflow: hidden !important;
  position: fixed;
  width: 100%;
  left: 0;
  right: 0;
}

html.phx-sidebar-open {
  overflow: hidden !important;
}

/* ── Responsive ── */
@media (max-width: 980px) {
  :root {
    --phx-header-h: 64px;
  }

  .phx-header-center,
  .main-nav {
    display: none !important;
  }

  .phx-header-brand-name {
    display: none;
  }

  /* ساعت + نام سامانه خیلی کوچک زیر آن در موبایل هم دیده شود */
  .phx-header-clock-stack {
    display: flex;
  }

  .phx-header-clock {
    display: flex;
    padding: 4px 8px;
    gap: 6px;
  }

  .phx-header-clock-icon {
    width: 14px;
    height: 14px;
  }

  .phx-clock-time {
    font-size: 12px;
    min-width: 6.8ch;
  }

  .phx-clock-date {
    font-size: 10px;
  }

  .phx-header-page-title {
    display: block;
    position: static;
    left: auto;
    top: auto;
    transform: none;
    font-size: 8.5px;
    font-weight: 600;
    color: var(--muted, #7C8479);
    max-width: min(34vw, 130px);
    pointer-events: none;
    z-index: 1;
  }

  /* کاربر بدون ساختمان: نام برند هم بماند */
  .phx-header--onboarding .phx-header-brand-name {
    display: inline-block;
    font-size: 13px;
    max-width: 72px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
  }

  .phx-header-brand-group {
    direction: ltr;
    gap: 8px;
  }

  .phx-header-actions-main {
    direction: ltr;
    gap: 10px;
  }

  .phx-header-user {
    border-right: none;
    padding-right: 0;
    direction: rtl;
  }

  .phx-header-logout {
    display: none;
  }

  .phx-header-identity {
    max-width: 170px;
  }

  .phx-header-username {
    font-size: 13px;
  }

  .phx-header-mobile {
    font-size: 9.5px;
  }

  .phx-header-profile-btn {
    font-size: 10px;
    padding: 2px 7px 2px 6px;
  }

  .phx-notif-btn {
    background: #F5F4EE;
    border-color: #F5F4EE;
  }

  .phx-notif-btn:hover {
    background: #EBEAE4;
    border-color: #EBEAE4;
  }

  /* موبایل: کارت جمع‌وجور؛ موقعیت دقیق با JS زیر خود زنگوله ست می‌شود */
  .phx-notif-panel {
    position: fixed;
    top: calc(var(--phx-header-h, 56px) + 4px);
    left: 10px;
    right: auto;
    width: min(292px, calc(100vw - 20px));
    max-width: min(292px, calc(100vw - 20px));
    max-height: min(46vh, 300px);
    display: flex;
    flex-direction: column;
    border-radius: 12px;
    box-shadow: 0 8px 22px rgba(28, 43, 36, 0.12);
    transform-origin: top center;
    transform: translateY(-6px) scale(0.98);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .phx-notif-panel.is-open {
    transform: translateY(0) scale(1);
  }

  .phx-notif-panel[hidden] {
    display: none !important;
  }

  .phx-notif-panel-head {
    padding: 9px 12px;
  }

  .phx-notif-panel-head strong {
    font-size: 13px;
    font-weight: 700;
  }

  .phx-notif-clear-all {
    font-size: 11px;
  }

  .phx-notif-panel-list {
    max-height: none;
    flex: 1;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  .phx-notif-row {
    gap: 0;
  }

  .phx-notif-item {
    padding: 9px 4px 9px 12px;
    gap: 2px;
  }

  .phx-notif-item-tag {
    font-size: 10px;
    padding: 0 6px;
    font-weight: 600;
  }

  .phx-notif-item-title {
    font-size: 12px;
    font-weight: 700;
    line-height: 1.35;
  }

  .phx-notif-item-body {
    font-size: 11px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }

  .phx-notif-dismiss {
    width: 28px;
    height: 28px;
    margin: 8px 6px 0 8px;
    border-radius: 7px;
  }

  .phx-notif-dismiss svg {
    width: 14px;
    height: 14px;
  }

  .phx-notif-empty {
    padding: 16px 12px;
    font-size: 12px;
  }

  .phx-mobile-menu-btn {
    display: inline-flex;
    background: var(--surface);
    border-color: var(--ink);
  }

  .phx-mobile-menu-btn:hover {
    background: #F5F4EE;
    border-color: var(--ink);
  }

  .phx-sidebar-overlay {
    display: block;
  }

  .phx-sidebar {
    display: flex;
    top: var(--phx-header-h, 56px);
    height: calc(100vh - var(--phx-header-h, 56px));
    height: calc(100dvh - var(--phx-header-h, 56px));
  }

  .phx-sidebar-overlay {
    top: var(--phx-header-h, 56px);
    bottom: 0;
    left: 0;
    right: 0;
  }
}

@media (max-width: 480px) {
  .phx-header-inner {
    padding: 0 10px 0 14px;
    gap: 8px;
  }

  .phx-header-actions {
    gap: 0;
  }

  .phx-notif-panel {
    max-height: min(42vh, 260px);
    border-radius: 11px;
  }

  .phx-notif-item {
    padding: 8px 2px 8px 10px;
  }

  .phx-notif-dismiss {
    width: 26px;
    height: 26px;
    margin: 7px 5px 0 6px;
  }

  .phx-notif-scrim.is-open {
    background: rgba(28, 43, 36, 0.28);
  }
}

/* هدف عمیق زنگوله: اسکرول دقیق زیر هدر ثابت */
[id^="invoice-"],
[id^="income-"],
[id^="announcement-"],
[id^="unit-invite-"],
[id^="manager-invite-"],
[id^="join-req-"],
.phx-acc-item {
  scroll-margin-top: calc(var(--phx-header-h, 62px) + 16px);
}

.phx-notif-target-focus {
  outline: 2px solid #0f766e !important;
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.18) !important;
  transition: box-shadow 0.25s ease, outline-color 0.25s ease;
}
