/* =============================================================
   Layout — app shell, sidebar, header, login
   ============================================================= */

/* Lock html/body color + scroll so Safari chrome doesn't pick up sidebar navy */
html:has(.app),
html:has(.app) body {
  height: 100%;
  overflow: hidden !important;
  background-color: #F8F9FA !important;
}
@media (prefers-color-scheme: dark) {
  html:has(.app):not([data-theme="light"]),
  html:has(.app):not([data-theme="light"]) body {
    background-color: #0A1628 !important;
  }
}
html[data-theme="light"]:has(.app),
html[data-theme="light"]:has(.app) body {
  background-color: #F8F9FA !important;
}
html[data-theme="dark"]:has(.app),
html[data-theme="dark"]:has(.app) body {
  background-color: #0A1628 !important;
}

body::after {
  content: '';
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 1px;
  background-color: #F8F9FA;
  z-index: 99999;
  pointer-events: none;
}
html[data-theme="dark"] body::after {
  background-color: #0A1628;
}

/* ---------- App shell ---------- */
.app {
  --side-gap: 8px;
  --side-radius: 16px;
  display: grid;
  grid-template-columns: var(--side-w) 1fr;
  height: 100%;
  min-height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  transition: grid-template-columns var(--t);
  background: var(--bg);
  gap: var(--side-gap);
  padding: var(--side-gap);
  box-sizing: border-box;
}
.app.collapsed { grid-template-columns: var(--side-w-collapsed) 1fr; }

/* ---------- Sidebar ---------- */
.sidebar {
  background: linear-gradient(180deg, #0A1628 0%, #0C2F55 40%, #0E4A7A 70%, #1463A8 100%);
  color: var(--text-on-dark);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: var(--side-gap);
  align-self: start;
  height: calc(100vh - (var(--side-gap) * 2));
  max-height: calc(100vh - (var(--side-gap) * 2));
  z-index: var(--z-sidebar);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: var(--side-radius);
  overflow: hidden;
  box-shadow:
    0 10px 36px rgba(8, 24, 48, .18),
    0 2px 8px rgba(8, 24, 48, .08);
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 18px 16px 14px;
  min-height: var(--header-h);
}
.brand-mark { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(145deg, #4BA3E8 0%, #2E7BC7 100%);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(46, 123, 199, .35);
}
.brand-logo img, .brand-logo svg { width: 20px; height: 20px; display: block; }
.brand-txt { overflow: hidden; white-space: nowrap; min-width: 0; }
.brand-txt h1 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: #FFFFFF;
  line-height: 1.15;
  letter-spacing: .01em;
}
.brand-txt span {
  display: block;
  font-size: 11px;
  color: rgba(186, 208, 232, .72);
  font-weight: 500;
  margin-top: 2px;
}
.side-collapse {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid rgba(186, 208, 232, .28);
  background: transparent;
  color: rgba(186, 208, 232, .85);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: var(--t-fast);
}
.side-collapse svg { width: 16px; height: 16px; }
.side-collapse:hover {
  background: rgba(255,255,255,.08);
  color: #FFFFFF;
  border-color: rgba(186, 208, 232, .45);
}
.app.collapsed .brand { justify-content: center; padding-inline: 10px; flex-direction: column; gap: 8px; }
.app.collapsed .brand-txt { display: none; }
.app.collapsed .brand-mark { justify-content: center; }
.app.collapsed .side-collapse { display: grid; }

.side-scroll { flex: 1; overflow-y: auto; padding: 6px 12px 16px; }
.side-scroll::-webkit-scrollbar { width: 4px; }
.side-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 4px; }

.nav-group { margin-top: 18px; }
.nav-group:first-child { margin-top: 6px; }
.nav-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  color: rgba(148, 173, 201, .78);
  padding: 0 12px 8px;
  text-transform: none;
}
.app.collapsed .nav-label { text-align: center; font-size: 0; padding-bottom: 4px; }
.app.collapsed .nav-label::after { content: "•"; font-size: 12px; color: rgba(148, 173, 201, .55); }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  color: rgba(230, 238, 248, .88);
  font-size: var(--fs-base);
  font-weight: 500;
  margin-bottom: 2px;
  position: relative;
  transition: var(--t-fast);
  cursor: pointer;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; color: rgba(210, 226, 242, .88); stroke-width: 1.7; }
.nav-item .nav-name { overflow: hidden; white-space: nowrap; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #FFFFFF; }
.nav-item:hover svg { color: #FFFFFF; }
.nav-item.active {
  background: rgba(255, 255, 255, .12);
  color: #FFFFFF;
  font-weight: 600;
  box-shadow: none;
}
.nav-item.active svg { color: #FFFFFF; }
.nav-item.active::before { display: none; }
.nav-item .nav-badge {
  margin-inline-start: auto;
  background: var(--red);
  color: #FFFFFF;
  font-size: 10px;
  font-weight: 800;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: var(--r-pill);
  display: grid;
  place-items: center;
}
.nav-item .nav-badge:empty, .nav-item .nav-badge[hidden] { display: none; }
.app.collapsed .nav-item { justify-content: center; padding: 11px; }
.app.collapsed .nav-item .nav-name, .app.collapsed .nav-item .nav-badge { display: none; }

/* Floating tip (ported to body — sidebar overflow would clip ::after tooltips) */
.side-nav-tip {
  position: fixed;
  z-index: calc(var(--z-dropdown) + 5);
  padding: 7px 11px;
  border-radius: 8px;
  background: #0A1628;
  color: #FFFFFF;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(8, 24, 48, .28);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-50%) scale(.96);
  transition: opacity .12s ease, visibility .12s ease, transform .12s ease;
}
.side-nav-tip.is-on {
  opacity: 1;
  visibility: visible;
  transform: translateY(-50%) scale(1);
}
.side-nav-tip::before {
  content: "";
  position: absolute;
  top: 50%;
  width: 0;
  height: 0;
  border: 6px solid transparent;
  transform: translateY(-50%);
}
.side-nav-tip[data-place="right"]::before {
  left: -6px;
  border-right-color: #0A1628;
  border-left-width: 0;
}
.side-nav-tip[data-place="left"]::before {
  right: -6px;
  border-left-color: #0A1628;
  border-right-width: 0;
}
@media (max-width: 920px) {
  .side-nav-tip { display: none !important; }
}

.side-foot {
  padding: 10px 12px 14px;
  border-top: 1px solid rgba(255,255,255,.1);
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: linear-gradient(180deg, transparent 0%, rgba(8, 30, 58, .18) 100%);
}
.wa-status {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #277651b8;
  border: 1px solid rgba(74, 222, 128, .35);
  border-radius: 12px;
  padding: 9px 11px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}
.wa-status .pulse {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #22C55E;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, .22);
  flex-shrink: 0;
  animation: pulse 2s infinite;
}
.wa-status .ws-txt { overflow: hidden; white-space: nowrap; min-width: 0; }
.wa-status .ws-txt strong {
  display: block;
  font-size: 12px;
  color: #ECFDF5;
  font-weight: 700;
  letter-spacing: .01em;
}
.wa-status .ws-txt span {
  font-size: 11px;
  color: rgba(167, 243, 208, .88);
}
.wa-status.wa-disconnected {
  background: #6e1620c7;
  border-color: rgba(248, 113, 113, .42);
}
.wa-status.wa-disconnected .pulse {
  background: #EF4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, .22);
  animation: none;
}
.wa-status.wa-disconnected .ws-txt strong { color: #FEF2F2; }
.wa-status.wa-disconnected .ws-txt span { color: rgba(254, 202, 202, .9); }

.side-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 2px 2px;
  min-width: 0;
}
.side-user .su-av {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(145deg, #4BA3E8 0%, #2E7BC7 100%);
  color: #FFFFFF;
  font-size: 12px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  letter-spacing: -.02em;
}
.side-user .su-txt { min-width: 0; flex: 1; overflow: hidden; }
.side-user .su-txt strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #FFFFFF;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}
.side-user .su-txt span {
  display: block;
  font-size: 11px;
  color: rgba(186, 208, 232, .72);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}
.side-logout {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: rgba(186, 208, 232, .8);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: var(--t-fast);
}
.side-logout svg { width: 18px; height: 18px; }
[dir="rtl"] .side-logout svg { transform: scaleX(-1); }
.side-logout:hover { background: rgba(220, 38, 38, .16); color: #F5C4C5; }

.app.collapsed .wa-status .ws-txt,
.app.collapsed .side-user .su-txt,
.app.collapsed .side-logout { display: none; }
.app.collapsed .wa-status,
.app.collapsed .side-user { justify-content: center; }
.app.collapsed .side-foot { padding-inline: 10px; }

/* ---------- Main column ---------- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

/* ---------- Header ---------- */
.header {
  height: var(--header-h);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--side-radius);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 22px;
  position: sticky;
  top: var(--side-gap);
  z-index: var(--z-header);
  width: 100%;
  min-width: 0;
  flex-shrink: 0;
  box-sizing: border-box;
}
.menu-toggle { display: none; }
.crumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-sm);
  color: var(--text-2);
  min-width: 0;
  flex: 1;
  overflow: hidden;
}
.crumb .cur {
  color: var(--text);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  font-size: 14px;
}
.crumb svg { width: 14px; height: 14px; color: var(--text-3); flex-shrink: 0; }
.header .h-search { width: min(360px, 32vw); margin-inline-start: auto; flex-shrink: 1; min-width: 0; }
.header-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.header-actions.no-search { margin-inline-start: auto; }
.header-search-menu {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--sh-lg);
  z-index: var(--z-dropdown);
  max-height: min(360px, 62vh);
  overflow-y: auto;
  padding: 6px;
}
.header-search-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: var(--r-xs);
  color: var(--text);
  text-align: start;
  transition: var(--t-fast);
}
.header-search-item:hover,
.header-search-item.active { background: var(--gold-tint); }
.header-search-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: var(--r-xs);
  background: var(--gold-tint);
  color: var(--gold);
}
.header-search-icon svg { width: 18px; height: 18px; }
.header-search-text { min-width: 0; flex: 1; }
.header-search-item strong {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 600;
}
.header-search-item small {
  display: block;
  color: var(--text-2);
  font-size: 11px;
  margin-top: 2px;
}
.header-search-empty {
  padding: 10px 12px;
  color: var(--text-2);
  font-size: var(--fs-sm);
}

.h-divider { width: 1px; height: 26px; background: var(--line); margin: 0 4px; }

/* profile chip */
.profile-chip { display: flex; align-items: center; gap: 9px; padding: 5px 6px 5px 10px; border-radius: var(--r-sm); transition: var(--t); position: relative; }
[dir="ltr"] .profile-chip { padding: 5px 10px 5px 6px; }
.profile-chip:hover { background: var(--bg-2); }
.profile-chip .pc-txt { text-align: end; line-height: 1.2; }
.profile-chip .pc-txt strong { font-size: var(--fs-sm); font-weight: 600; display: block; }
.profile-chip .pc-txt span { font-size: var(--fs-xs); color: var(--text-2); }
.profile-chip .pc-av { width: 36px; height: 36px; border-radius: var(--r-sm); background: var(--grad-gold); display: grid; place-items: center; color: var(--on-gold); font-weight: 800; }
@media (max-width: 720px) { .profile-chip .pc-txt { display: none; } }

/* notification dropdown */
.notif-anchor { position: relative; flex-shrink: 0; }
.notif-panel { position: absolute; inset-inline-end: 0; top: calc(100% + 10px); width: 360px; max-width: min(360px, calc(100vw - 24px)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--sh-lg); z-index: var(--z-dropdown); animation: pop var(--t-fast) both; overflow: hidden; }
@media (min-width: 721px) {
  .header-actions { position: relative; }
}
@media (max-width: 720px) {
  .notif-panel {
    position: fixed;
    top: calc(var(--header-h) + env(safe-area-inset-top, 0px) + 6px);
    inset-inline-start: 0;
    inset-inline-end: 0;
    width: min(360px, calc(100vw - 20px));
    max-width: calc(100vw - 20px);
    margin-inline: auto;
  }
  .notif-list { max-height: min(380px, 55vh); }
}
.notif-panel .np-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.notif-panel .np-head h4 { font-size: var(--fs-md); }
.notif-panel .np-head button { font-size: var(--fs-xs); color: var(--gold-deep); font-weight: 600; }
.notif-list { max-height: 380px; overflow-y: auto; }
.notif-row { display: flex; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--line); transition: var(--t-fast); cursor: pointer; }
.notif-row:hover { background: var(--bg-2); }
.notif-row.unread { background: var(--gold-tint); }
.notif-row .nic { width: 36px; height: 36px; border-radius: var(--r-xs); display: grid; place-items: center; flex-shrink: 0; }
.notif-row .nic svg { width: 16px; height: 16px; }
.nic.ic-ai { background: var(--ai-tint); color: var(--ai); }
.nic.ic-green { background: var(--green-tint); color: var(--green); }
.nic.ic-gold { background: var(--gold-tint); color: var(--gold-deep); }
.nic.ic-blue { background: var(--blue-tint); color: var(--blue); }
.nic.ic-red { background: var(--red-tint); color: var(--red); }
.notif-row .nr-txt strong { font-size: var(--fs-sm); font-weight: 600; display: block; }
.notif-row .nr-txt p { font-size: var(--fs-xs); color: var(--text-2); margin: 2px 0; line-height: 1.5; }
.notif-row .nr-txt time { font-size: 10.5px; color: var(--text-3); }
.np-foot { padding: 11px; text-align: center; }
.np-foot button { font-size: var(--fs-sm); color: var(--gold-deep); font-weight: 600; }

/* ---------- Content ---------- */
.content { flex: 1; padding: 24px 22px 40px; overflow-x: hidden; min-height: 0; }
.content.flush { padding: 0; overflow: hidden; }
.container { max-width: var(--maxw); margin: 0 auto; }
.page { display: none; animation: fadeIn var(--t) both; }
.page.active { display: block; }

/* grids */
.grid { display: grid; gap: 18px; }
.grid > * { min-width: 0; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.span-2 { grid-column: span 2; }
/* asymmetric 2-col (overview/reports charts) — minmax(0,…) lets canvas/cards shrink */
.grid-split {
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
}
.grid-split.wide-main {
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
}
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-split,
  .grid-split.wide-main { grid-template-columns: 1fr; }
}
@media (max-width: 680px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } .span-2 { grid-column: span 1; } }
/* phones: collapse any 2-col layout to a single column, even when inline styles set them */
@media (max-width: 720px) { .grid[style*="grid-template-columns"] { grid-template-columns: 1fr !important; } }

/* ---------- Mobile Sidebar Drawer ---------- */
.scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(8, 24, 48, .48);
  backdrop-filter: blur(6px) saturate(1.05);
  -webkit-backdrop-filter: blur(6px) saturate(1.05);
  z-index: calc(var(--z-header) + 5);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity .28s var(--ease-out, cubic-bezier(.22, 1, .36, 1)),
    visibility .28s;
}

@media (max-width: 920px) {
  .app, .app.collapsed {
    grid-template-columns: 1fr;
    padding: 0;
    gap: 0;
  }

  .scrim {
    display: block;
    inset: 0;
    z-index: calc(var(--z-header) + 5);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    inset-inline-start: 0;
    inset-inline-end: auto;
    width: min(320px, calc(100vw - 56px));
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    /* Hide toward the docked edge: left in LTR, right in RTL */
    transform: translateX(-104%);
    transition:
      transform .34s cubic-bezier(.22, 1, .36, 1),
      box-shadow .34s ease;
    border-radius: 0;
    border-inline-end: 1px solid rgba(255,255,255,.08);
    border-inline-start: none;
    box-shadow: none;
    z-index: calc(var(--z-header) + 6);
    overscroll-behavior: contain;
  }
  [dir="rtl"] .sidebar {
    transform: translateX(104%);
    border-inline-end: none;
    border-inline-start: 1px solid rgba(255,255,255,.08);
  }

  .sidebar .brand {
    display: flex;
    flex-shrink: 0;
    min-height: var(--header-h);
    padding: 14px 14px 12px;
    border-bottom: 1px solid rgba(255,255,255,.08);
  }
  .sidebar .side-collapse {
    display: grid;
    border-color: rgba(255,255,255,.14);
    background: rgba(255,255,255,.06);
  }
  .sidebar .side-collapse:hover {
    background: rgba(255,255,255,.12);
    color: #fff;
  }
  .sidebar .side-scroll {
    flex: 1 1 auto;
    min-height: 0;
    padding: 10px 12px 18px;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar .nav-item {
    min-height: 46px;
    padding: 12px 14px;
    border-radius: 14px;
    font-size: var(--fs-md);
    gap: 14px;
  }
  .sidebar .nav-item svg {
    width: 20px;
    height: 20px;
  }
  .sidebar .nav-group {
    margin-top: 20px;
  }
  .sidebar .nav-label {
    padding: 0 14px 10px;
    font-size: 12px;
  }
  .sidebar .side-foot {
    flex-shrink: 0;
    padding: 12px 12px calc(14px + env(safe-area-inset-bottom, 0px));
`  }
  .sidebar .wa-status,
  .sidebar .side-user {
    min-height: 48px;
    border-radius: 14px;
  }

  .app.nav-open .sidebar,
  [dir="rtl"] .app.nav-open .sidebar {
    transform: translateX(0);
    box-shadow:
      0 0 0 1px rgba(255,255,255,.04),
      24px 0 64px rgba(8, 24, 48, .35);
  }
  [dir="rtl"] .app.nav-open .sidebar {
    box-shadow:
      0 0 0 1px rgba(255,255,255,.04),
      -24px 0 64px rgba(8, 24, 48, .35);
  }

  .app.nav-open .scrim {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
  body:has(.app.nav-open) {
    overflow: hidden;
    touch-action: none;
  }

  html.is-page-loading .sidebar {
    visibility: hidden;
    pointer-events: none;
    transition: none;
  }

  .menu-toggle {
    display: inline-flex;
    flex-shrink: 0;
    background: var(--gold-tint);
    border-color: transparent;
    color: var(--gold-deep);
  }
  .menu-toggle:hover { background: var(--gold-tint-2); color: var(--gold-deep); }
  .app.nav-open .menu-toggle {
    background: var(--gold);
    color: var(--on-gold);
  }

  .header {
    padding: 0 12px;
    gap: 8px;
    padding-top: env(safe-area-inset-top, 0);
    height: calc(var(--header-h) + env(safe-area-inset-top, 0));
    border-radius: 0;
    border: none;
    border-bottom: 1px solid var(--line);
    top: 0;
  }
  .header .h-search { width: auto; flex: 1; min-width: 0; margin-inline-start: 0; }
  .header .h-search input { font-size: var(--fs-xs); }
  .crumb { font-size: var(--fs-xs); flex: 1; }
  .h-divider { display: none; }
  .content { padding: 16px 14px 28px; }
  .page-head h2 { font-size: var(--fs-xl); }
  .page-head p { font-size: var(--fs-sm); }
}

/* MD / tablet drawer: a bit roomier */
@media (max-width: 920px) and (min-width: 561px) {
  .sidebar {
    width: min(340px, calc(100vw - 72px));
  }
  .sidebar .nav-item {
    min-height: 48px;
  }
  .sidebar .side-scroll {
    padding: 12px 14px 20px;
  }
}

@media (max-width: 560px) {
  .header { padding: 0 10px; gap: 4px; padding-top: env(safe-area-inset-top, 0); }
  .header .h-search { display: none; }   /* tight phones: hide global search, keep page-level search */
  .crumb > span:first-child { display: none; }   /* drop the brand prefix; keep current page */
  .crumb svg { display: none; }
  .header-actions { gap: 2px; }
  .icon-btn { width: 36px; height: 36px; }
  .icon-btn svg { width: 18px; height: 18px; }
  .pc-av { width: 32px !important; height: 32px !important; }
  .content { padding: 14px 12px 24px; }
  .sidebar {
    width: min(300px, calc(100vw - 48px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .scrim,
  .sidebar {
    transition: none !important;
  }
}

/* =============================================================
   Login (split screen) 
   ============================================================= */
.login {
  --login-deep: #0D0065;
  --login-mid: #1E2FA0;
  --login-bright: #3C69E3;
  --login-soft: #6B8EF0;
  --login-glow: rgba(60, 105, 227, .35);
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
}

.login-hero {
  background:
    radial-gradient(ellipse 80% 60% at 100% 0%, rgba(60, 105, 227, .45), transparent 55%),
    radial-gradient(ellipse 70% 50% at 0% 100%, rgba(13, 0, 101, .8), transparent 50%),
    linear-gradient(155deg, #0D0065 0%, #15207A 38%, #2A4CC4 72%, #3C69E3 100%);
  color: var(--text-on-dark);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px 54px;
  animation: loginHeroIn .7s cubic-bezier(.22, 1, .36, 1) both;
}
.login-hero::before,
.login-hero::after { display: none; }

.hero-orb {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(2px);
  z-index: 0;
}
.hero-orb-a {
  width: 420px;
  height: 420px;
  top: -140px;
  inset-inline-end: -120px;
  background: radial-gradient(circle, rgba(107, 142, 240, .45), transparent 68%);
  animation: loginOrbFloat 9s ease-in-out infinite;
}
.hero-orb-b {
  width: 340px;
  height: 340px;
  bottom: -100px;
  inset-inline-start: -90px;
  background: radial-gradient(circle, rgba(13, 0, 101, .55), transparent 70%);
  animation: loginOrbFloat 11s ease-in-out infinite reverse;
}

.hero-comb {
  position: absolute;
  inset: 0;
  opacity: .07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='48' viewBox='0 0 56 48'%3E%3Cpath d='M4 40 L28 8 L52 40' fill='none' stroke='%23FFFFFF' stroke-width='2'/%3E%3C/svg%3E");
  background-size: 56px auto;
  z-index: 0;
}
.login-hero > *:not(.hero-comb):not(.hero-orb) { position: relative; z-index: 1; }

.lh-top { display: flex; align-items: center; gap: 13px; }
.lh-logo { width: 52px; height: 52px; border-radius: var(--r-md); background: transparent; display: grid; place-items: center; box-shadow: none; }
.lh-logo img, .lh-logo svg { width: 36px; height: 36px; display: block; }
.lh-top h1 { font-family: var(--font-display); font-size: var(--fs-2xl); color: #FFFFFF; }
.lh-top span { font-size: var(--fs-sm); color: rgba(255,255,255,.65); display: block; }
.lh-mid { max-width: 440px; }
.lh-tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.22);
  backdrop-filter: blur(8px);
  color: #FFFFFF;
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: 7px 14px;
  border-radius: var(--r-pill);
  margin-bottom: 22px;
  transition: background .2s ease, border-color .2s ease, transform .2s ease;
}
.lh-tag:hover {
  background: rgba(255,255,255,.18);
  border-color: rgba(255,255,255,.35);
  transform: translateY(-1px);
}
.lh-mid h2 { font-family: var(--font-display); font-size: 34px; line-height: 1.3; color: #FFFFFF; margin-bottom: 14px; text-wrap: balance; }
[dir="ltr"] .lh-mid h2 { font-family: var(--font-latin-display); }
.lh-mid > p { color: rgba(255,255,255,.78); font-size: var(--fs-md); line-height: 1.7; }
.lh-feats { margin-top: 30px; display: flex; flex-direction: column; gap: 14px; }
.lh-feats li {
  display: flex;
  align-items: center;
  gap: 13px;
  font-size: var(--fs-base);
  color: rgba(255,255,255,.92);
  padding: 8px 10px;
  border-radius: 12px;
  transition: background .2s ease, transform .2s ease;
}
.lh-feats li:hover {
  background: rgba(255,255,255,.08);
  transform: translateX(calc(-4px * var(--dir, 1)));
}
[dir="ltr"] .lh-feats li:hover { transform: translateX(4px); }
.lh-feats .fic {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(145deg, rgba(255,255,255,.18), rgba(255,255,255,.06));
  border: 1px solid rgba(255,255,255,.2);
  display: grid;
  place-items: center;
  color: #D6E4FF;
  flex-shrink: 0;
  transition: transform .25s ease, box-shadow .25s ease;
}
.lh-feats li:hover .fic {
  transform: scale(1.06);
  box-shadow: 0 6px 16px rgba(13, 0, 101, .35);
}
.lh-feats .fic svg { width: 18px; height: 18px; }
.lh-foot { font-size: var(--fs-xs); color: rgba(255,255,255,.55); }

.login-form-side {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background:
    radial-gradient(ellipse 70% 50% at 100% 0%, rgba(60, 105, 227, .08), transparent 55%),
    radial-gradient(ellipse 50% 40% at 0% 100%, rgba(13, 0, 101, .05), transparent 50%),
    var(--surface);
  position: relative;
  min-width: 0;
  overflow-y: auto;
}
.login-top-actions { position: absolute; top: 22px; inset-inline-end: 26px; display: flex; gap: 8px; z-index: 2; }
.login-icon-btn {
  transition: transform .2s ease, background .2s ease, border-color .2s ease, color .2s ease, box-shadow .2s ease;
}
.login-icon-btn:hover {
  transform: translateY(-2px);
  color: var(--login-bright);
  border-color: rgba(60, 105, 227, .35);
  background: rgba(60, 105, 227, .08);
  box-shadow: 0 6px 16px rgba(60, 105, 227, .12);
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 8px;
}
.login-card .lc-head { margin-bottom: 28px; }
.login-card .lc-head h3 {
  font-size: var(--fs-2xl);
  font-family: var(--font-display);
  background: linear-gradient(120deg, var(--login-deep), var(--login-bright));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
[data-theme="dark"] .login-card .lc-head h3 {
  background: linear-gradient(120deg, #8EA8F5, #3C69E3);
  -webkit-background-clip: text;
  background-clip: text;
}
[dir="ltr"] .login-card .lc-head h3 { font-family: var(--font-latin-display); }
.login-card .lc-head p { color: var(--text-2); margin-top: 6px; line-height: 1.55; }

.login-input {
  transition: transform .2s ease;
}
.login-input .input {
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.login-input:hover .input {
  border-color: rgba(60, 105, 227, .4);
}
.login-input .input:focus {
  border-color: var(--login-bright);
  box-shadow: 0 0 0 4px rgba(60, 105, 227, .16);
  background: var(--surface);
}
.login-input:focus-within > [data-icon],
.login-input:focus-within > svg {
  color: var(--login-bright);
}

.login-row { display: flex; align-items: center; justify-content: space-between; margin: -4px 0 20px; }
.login-row label { display: flex; align-items: center; gap: 7px; font-size: var(--fs-sm); color: var(--text-2); cursor: pointer; transition: color .15s ease; }
.login-row label:hover { color: var(--text); }
.login-row label input { accent-color: var(--login-bright); width: 15px; height: 15px; }
.login-row a { font-size: var(--fs-sm); color: var(--login-bright); font-weight: 600; }
.login-demo { margin-top: 22px; padding: 13px 15px; background: rgba(60, 105, 227, .08); border: 1px dashed rgba(60, 105, 227, .4); border-radius: var(--r-sm); font-size: var(--fs-xs); color: var(--login-mid); line-height: 1.7; }
.login-demo strong { color: var(--text); }

.login-submit {
  background: linear-gradient(135deg, #0D0065 0%, #2A4CC4 48%, #3C69E3 100%) !important;
  box-shadow: 0 8px 22px rgba(60, 105, 227, .35) !important;
  border: none;
  position: relative;
  overflow: hidden;
  transition: transform .22s ease, box-shadow .22s ease, filter .22s ease !important;
}
.login-submit::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 20%, rgba(255,255,255,.22) 50%, transparent 80%);
  transform: translateX(-120%);
  transition: transform .55s ease;
}
.login-submit:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 12px 28px rgba(60, 105, 227, .45) !important;
  filter: brightness(1.05);
}
.login-submit:hover::after { transform: translateX(120%); }
.login-submit:active { transform: translateY(0) !important; }

.pass-wrap { display: flex; align-items: stretch; gap: 8px; }
.pass-eye { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: var(--r-sm); flex-shrink: 0; color: var(--text-3); }
.pass-eye:hover {
  color: var(--login-bright);
  border-color: rgba(60, 105, 227, .45);
  background: rgba(60, 105, 227, .08);
}

/* Entry animations */
.login-reveal {
  opacity: 0;
  animation: loginReveal .7s cubic-bezier(.22, 1, .36, 1) both;
  animation-delay: var(--d, 0s);
}
@keyframes loginReveal {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes loginHeroIn {
  from { opacity: 0; transform: translateX(calc(24px * var(--dir, 1))); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes loginOrbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(12px, -16px) scale(1.05); }
}
@media (prefers-reduced-motion: reduce) {
  .login-reveal,
  .login-hero,
  .hero-orb-a,
  .hero-orb-b { animation: none !important; opacity: 1 !important; transform: none !important; }
  .login-submit::after { display: none; }
}

/* =============================================================
   Mobile login
   ============================================================= */
@media (min-width: 881px) {
  .login-form-side .mob-brand { display: none; }
}
@media (max-width: 1100px) and (min-width: 881px) {
  .login { grid-template-columns: minmax(0, .95fr) minmax(0, 1fr); }
  .login-hero { padding: 36px 36px; }
  .lh-mid h2 { font-size: 28px; }
  .lh-logo-login { width: min(220px, 100%); }
}
@media (max-width: 880px) {
  .login {
    grid-template-columns: 1fr;
    overflow-x: hidden;
    overflow-y: auto;
    min-height: 100vh;
    min-height: 100dvh;
  }
  .login-hero { display: none; }

  .login-form-side {
    padding: 0;
    padding-bottom: env(safe-area-inset-bottom, 0);
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    min-height: 100vh;
    min-height: 100dvh;
    position: relative;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .login-form-side::before {
    content: "";
    position: absolute;
    top: -120px;
    inset-inline-start: 50%;
    transform: translateX(-50%);
    width: min(480px, 140vw);
    height: min(480px, 140vw);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(60, 105, 227, .22), transparent 65%);
    z-index: 0;
    pointer-events: none;
  }

  .login-top-actions {
    position: relative;
    inset: auto;
    padding: 16px 24px 0;
    padding-top: max(16px, env(safe-area-inset-top, 0px));
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    z-index: 2;
    flex-shrink: 0;
  }

  .login-form-side .mob-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 24px 24px 4px;
    z-index: 2;
    position: relative;
    text-align: center;
    flex-shrink: 0;
  }
  .login-form-side .mob-brand .mb-logo {
    width: 68px;
    height: 68px;
    border-radius: 20px;
    background: linear-gradient(145deg, rgba(60, 105, 227, .12), rgba(13, 0, 101, .06));
    border: 1px solid rgba(60, 105, 227, .18);
    display: grid;
    place-items: center;
    box-shadow: 0 10px 28px rgba(60, 105, 227, .12);
  }
  .login-form-side .mob-brand .mb-logo img,
  .login-form-side .mob-brand .mb-logo svg { width: 42px; height: 42px; display: block; }
  .login-form-side .mob-brand h1 {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin-top: 4px;
  }
  .login-form-side .mob-brand span {
    font-size: var(--fs-xs);
    color: var(--text-2);
    letter-spacing: .02em;
  }

  .login-card {
    margin: 28px 24px 0;
    padding: 28px 22px 26px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(13, 0, 101, .08);
    z-index: 2;
    max-width: none;
    width: auto;
    flex-shrink: 0;
  }
  .login-card .lc-head { margin-bottom: 22px; text-align: start; }
  .login-card .lc-head h3 { font-size: 22px; font-weight: 700; }
  .login-card .lc-head p { color: var(--text-2); font-size: var(--fs-sm); margin-top: 6px; }

  .login-form-side::after {
    content: "© 2026 سكة · Sekaa For Real Estate";
    display: block;
    margin: auto 24px 18px;
    padding-top: 28px;
    text-align: center;
    font-size: var(--fs-xs);
    color: var(--text-3);
    letter-spacing: .02em;
    z-index: 2;
    position: relative;
    flex-shrink: 0;
  }
  [dir="ltr"] .login-form-side::after { content: "© 2026 Sekaa For Real Estate"; }
}

/* Short / landscape phones: keep form usable without clipping */
@media (max-width: 880px) and (max-height: 700px) {
  .login-form-side .mob-brand { padding: 12px 24px 0; gap: 8px; }
  .login-form-side .mob-brand .mb-logo { width: 52px; height: 52px; border-radius: 16px; }
  .login-form-side .mob-brand .mb-logo img,
  .login-form-side .mob-brand .mb-logo svg { width: 32px; height: 32px; }
  .login-form-side .mob-brand h1 { font-size: 18px; margin-top: 0; }
  .login-card { margin-top: 16px; padding: 20px 18px 18px; }
  .login-card .lc-head { margin-bottom: 16px; }
  .login-form-side::after { margin-bottom: 12px; padding-top: 16px; }
}

@media (max-width: 380px) {
  .login-top-actions { padding: 14px 16px 0; padding-top: max(14px, env(safe-area-inset-top, 0px)); }
  .login-form-side .mob-brand { padding: 16px 16px 4px; }
  .login-card { margin: 20px 16px 0; padding: 22px 16px 20px; }
  .login-form-side::after { margin-inline: 16px; margin-bottom: 14px; }
  .pass-eye { width: 40px; height: 40px; }
}


.invert-50 {
  filter: invert(50%) brightness(2.25);
}

.lh-logo-login {
  width: 270px;
  height: auto;
}

.lh-logo-login img, .lh-logo-login svg {
  width: 100%;
  height: auto;
}

.brand-logo-dashboard {
  width: 150px;
  height: auto;
}

.brand-logo-dashboard img, .brand-logo-dashboard svg {
  width: 100%;
  height: auto;
}