/**
 * K697 shared app shell — topbar + sidebar (desktop + mobile)
 * Loaded after polish/phone via k697_phone_styles() — all systems.
 * Preserves: light default, safe-area, clear_tenant, bottom phone-nav.
 * Declutter: identity · search · user · «المزيد» overflow.
 */

:root {
  --k697-shell-top-h: 56px;
  --k697-shell-side-w: var(--sidebar-w, 248px);
  --k697-shell-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --k697-shell-dur: 0.28s;
}

/* ═══════════════════════════════════════════════════════════════════
   TOP BAR — grouped desktop · compact mobile (no wrap chaos)
   ═══════════════════════════════════════════════════════════════════ */
.topbar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 12px;
  min-height: var(--k697-shell-top-h);
  height: var(--k697-shell-top-h);
  padding: 0 16px 0 18px;
  background: var(--bg-card, #fffcf7) !important;
  border-bottom: 1px solid color-mix(in srgb, var(--border, #e4dccb) 88%, transparent);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.55) inset, 0 8px 24px -20px rgba(26, 22, 16, 0.35);
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  z-index: 100;
  overflow: visible;
}

.topbar::after {
  height: 1.5px;
  opacity: 0.55;
  background: linear-gradient(
    90deg,
    transparent 0%,
    color-mix(in srgb, var(--accent, #f0a030) 45%, transparent) 22%,
    var(--accent, #f0a030) 50%,
    color-mix(in srgb, var(--accent, #f0a030) 45%, transparent) 78%,
    transparent 100%
  );
}

/* Group 1 — identity (brand + short crumb + tenant) */
.topbar .hub-nav-top {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 1 auto;
  min-width: 0;
  max-width: min(38vw, 360px);
}

.topbar .hub-crumb {
  min-width: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 2px;
}

/* Desktop: collapse «البوابة» — brand already links home */
.topbar .hub-crumb__link,
.topbar .hub-crumb__sep {
  display: none;
}
.topbar .hub-crumb__here {
  max-width: 150px;
  font-weight: 800;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.88;
}

.topbar .hub-tenant-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-inline-start: 2px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent, #f0a030) 40%, transparent);
  background: color-mix(in srgb, var(--accent, #f0a030) 11%, transparent);
  color: inherit;
  font-size: 11.5px;
  font-weight: 800;
  white-space: nowrap;
  text-decoration: none;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 1;
  transition: background 0.18s var(--k697-shell-ease), border-color 0.18s var(--k697-shell-ease);
}
.topbar .hub-tenant-chip__txt {
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar .hub-tenant-chip:hover {
  background: color-mix(in srgb, var(--accent, #f0a030) 20%, transparent);
  border-color: color-mix(in srgb, var(--accent, #f0a030) 65%, transparent);
}

.topbar-menu-btn {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  border: 1px solid var(--border, #e4dccb);
  background: var(--bg-inset, #f6f1e7);
}

/* Group 2 — constrained search (does not dominate the bar) */
.topbar-search {
  flex: 0 1 240px;
  max-width: 260px;
  min-width: 140px;
  margin-inline-start: auto;
  margin-inline-end: 0;
}

.topbar-search input {
  width: 100%;
  min-height: 38px;
  border-radius: 11px;
  border: 1px solid var(--border, #e4dccb);
  background: var(--bg-inset, #f6f1e7);
  font-size: 13px;
  padding-block: 7px;
}

/* Group 3 — user + overflow */
.topbar-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  margin-inline-start: 0;
  margin-right: 0;
}

.topbar-date {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
  gap: 6px;
}

.topbar-user-chip {
  padding: 4px 12px 4px 5px;
  border-radius: 999px;
  gap: 8px;
  font-size: 12.5px;
  max-width: 160px;
}
.topbar-user-chip > span:not(.avatar) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-user-chip .avatar {
  width: 28px;
  height: 28px;
  font-size: 12px;
}

/* ── Overflow «المزيد» ─────────────────────────────────────────── */
.k697-top-more {
  position: relative;
  flex: 0 0 auto;
}
.k697-top-more__btn {
  position: relative;
  width: 38px;
  height: 38px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border-radius: 11px;
  border: 1px solid var(--border, #e4dccb);
  background: var(--bg-inset, #f6f1e7);
  color: inherit;
  cursor: pointer;
  transition: background 0.18s var(--k697-shell-ease), border-color 0.18s var(--k697-shell-ease),
    transform 0.18s var(--k697-shell-ease);
}
.k697-top-more__btn .kicon,
.k697-top-more__btn svg {
  width: 18px;
  height: 18px;
}
.k697-top-more__btn:hover,
.k697-top-more.is-open .k697-top-more__btn {
  background: color-mix(in srgb, var(--accent, #f0a030) 14%, transparent);
  border-color: color-mix(in srgb, var(--accent, #f0a030) 40%, transparent);
}
.k697-top-more__badge {
  position: absolute;
  top: 2px;
  inset-inline-end: 2px;
  min-width: 16px;
  padding: 2px 4px;
  border-radius: 99px;
  background: var(--danger, #ef4444);
  color: #fff;
  font: 800 9px/1 var(--font, "Cairo", sans-serif);
  font-style: normal;
  text-align: center;
  box-shadow: 0 0 0 2px var(--bg-card, #fffcf7);
  pointer-events: none;
  z-index: 1;
}
.k697-top-more__panel {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  z-index: 860;
  width: min(280px, calc(100vw - 24px));
  padding: 10px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--bg-card, #fffcf7) 98%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent, #f0a030) 22%, var(--border, #e4dccb));
  box-shadow: 0 18px 48px rgba(26, 22, 16, 0.18), 0 1px 0 rgba(255, 255, 255, 0.5) inset;
}
.k697-top-more__head {
  padding: 2px 6px 8px;
  font: 800 11.5px/1 var(--font, "Cairo", sans-serif);
  color: var(--text-muted, #6b6254);
  border-bottom: 1px dashed color-mix(in srgb, var(--border, #e4dccb) 55%, transparent);
  margin-bottom: 8px;
}
.k697-top-more__section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.k697-top-more__section--date {
  margin-bottom: 8px;
}
.k697-top-more__section--date .topbar-date {
  width: 100%;
  justify-content: flex-start;
  box-sizing: border-box;
}
.k697-top-more__section--tools {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.k697-top-more__section--tools .k697-bell,
.k697-top-more__section--tools .k697-theme-btn,
.k697-top-more__section--tools .k697-density-btn,
.k697-top-more__section--tools .k697-pin-btn,
.k697-top-more__tenant {
  width: 100%;
  justify-content: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 6px 10px !important;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  text-decoration: none;
  box-sizing: border-box;
  cursor: pointer;
}
.k697-top-more__tenant .kicon,
.k697-top-more__tenant svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.k697-top-more__section--tools .k697-bell__btn {
  width: auto;
  height: auto;
  min-height: 40px;
  flex: 1;
  justify-content: flex-start;
  gap: 10px;
  padding: 6px 10px !important;
  border-radius: 10px;
}
.k697-top-more__section--tools .k697-bell__btn::after {
  content: "التنبيهات";
  font: 750 12.5px/1.2 var(--font, "Cairo", sans-serif);
}
.k697-top-more__tool-label {
  font: 750 12.5px/1.2 var(--font, "Cairo", sans-serif);
}
.k697-top-more__section--tools .k697-theme-btn:hover,
.k697-top-more__section--tools .k697-density-btn:hover,
.k697-top-more__section--tools .k697-pin-btn:hover,
.k697-top-more__section--tools .k697-bell__btn:hover,
.k697-top-more__tenant:hover {
  background: color-mix(in srgb, var(--accent, #f0a030) 10%, transparent);
  border-color: color-mix(in srgb, var(--accent, #f0a030) 22%, transparent);
  transform: none;
}
.k697-top-more__section--tools .k697-bell {
  position: relative;
  margin: 0;
}
/* Badge stays on the overflow trigger — hide duplicate count inside the row */
.k697-top-more__section--tools .k697-bell__count {
  position: static;
  margin-inline-start: auto;
  box-shadow: none;
  border: 0;
  flex-shrink: 0;
}
.k697-top-more__section--tools .k697-bell__pop {
  inset-inline-end: 0;
  top: calc(100% + 4px);
}
/* Nested alerts sheet must stay closed until tapped (never paint over load) */
.k697-top-more__section--tools .k697-bell__pop[hidden] {
  display: none !important;
}

/* Desktop: keep one clean row */
@media (min-width: 901px) {
  .topbar {
    padding-inline: 20px 22px;
    gap: 14px;
  }
  .topbar-menu-btn { display: none !important; }
  .topbar-search-btn { display: none !important; }
  .topbar-search { display: block; }
  /* Date lives inside overflow — never inline on desktop */
  .topbar-meta > .topbar-date { display: none !important; }
}

/* ═══════════════════════════════════════════════════════════════════
   SIDEBAR — hierarchy · compact chrome · sticky desktop
   ═══════════════════════════════════════════════════════════════════ */
.sidebar {
  width: var(--k697-shell-side-w);
  flex: 0 0 var(--k697-shell-side-w);
  position: sticky;
  top: 0;
  align-self: stretch;
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 200;
  border-inline-start: 1px solid color-mix(in srgb, var(--accent, #f0a030) 18%, transparent);
  box-shadow: 18px 0 48px -28px rgba(0, 0, 0, 0.55);
  transition: transform var(--k697-shell-dur) var(--k697-shell-ease);
}

/* Soften scanline / noise so chrome feels cleaner */
.sidebar::after {
  opacity: 0.18;
}

.sidebar-header {
  flex: 0 0 auto;
  padding: 14px 12px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.sidebar-brand-icon {
  width: 40px;
  height: 40px;
  font-size: 18px;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
}

.sidebar-header h1 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 900;
  letter-spacing: 0.01em;
  line-height: 1.25;
}

.sidebar-header .user-sub {
  margin-top: 2px;
  font-size: 11.5px;
  opacity: 0.72;
  font-weight: 600;
}

.sidebar-header .sidebar-access {
  margin-top: 6px;
}

.sidebar-header .sidebar-access .badge--solid {
  font-size: 10.5px;
  padding: 3px 9px;
  border-radius: 999px;
}

/* Month pill — one dense row */
.sidebar-header .sidebar-pill.sidebar-pill--month {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 5px 9px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar-header .sidebar-pill.sidebar-pill--month.open {
  border-color: color-mix(in srgb, #4ade80 35%, transparent);
  background: color-mix(in srgb, #22c55e 10%, transparent);
}
.sidebar-header .sidebar-pill.sidebar-pill--month.closed {
  border-color: color-mix(in srgb, #f87171 30%, transparent);
  background: color-mix(in srgb, #ef4444 9%, transparent);
}
.sidebar-header .sidebar-pill.sidebar-pill--month .pill-label {
  max-width: 40%;
  font-size: 9.5px;
  opacity: 0.8;
}
.sidebar-header .sidebar-pill.sidebar-pill--month .pill-title {
  font-size: 12px;
  font-weight: 850;
}
.sidebar-header .sidebar-pill.sidebar-pill--month .pill-meta {
  font-size: 9.5px;
  opacity: 0.8;
  margin-inline-start: auto;
}

.sidebar-nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 0 10px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.sidebar-nav .nav-section-label {
  margin: 6px 14px 4px;
  padding: 0;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.45;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 1px 8px;
  padding: 7px 10px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  min-height: 36px;
  color: inherit;
  text-decoration: none;
  position: relative;
  transition: background 0.16s var(--k697-shell-ease), color 0.16s var(--k697-shell-ease),
    transform 0.16s var(--k697-shell-ease);
}

.sidebar-nav .nav-link:hover {
  background: rgba(255, 255, 255, 0.055);
  transform: none;
}

.sidebar-nav .nav-link.active {
  background: color-mix(in srgb, var(--accent, #f0a030) 15%, transparent);
  color: #fff;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent, #f0a030) 26%, transparent);
}

.sidebar-nav .nav-link.active::before {
  content: "";
  position: absolute;
  inset-block: 7px;
  inset-inline-start: 0;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent, #f0a030);
  box-shadow: 0 0 8px color-mix(in srgb, var(--accent, #f0a030) 45%, transparent);
}

.sidebar-nav .nav-link.active::after { content: none; }

.sidebar-nav .nav-link .nav-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.05);
  flex: 0 0 28px;
}

.sidebar-nav .nav-link.active .nav-icon {
  background: color-mix(in srgb, var(--accent, #f0a030) 22%, transparent);
  color: var(--accent, #f0a030);
}

.sidebar-nav .nav-link .nav-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Hub portal / switch — quieter chrome */
.sidebar-nav > a.hub-sidebar-portal,
aside.sidebar a.hub-sidebar-portal {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  margin: 0 8px 5px !important;
  padding: 5px 8px !important;
  border-radius: 9px !important;
  min-height: 32px !important;
  background: rgba(255, 255, 255, 0.03) !important;
  border: 1px solid rgba(255, 255, 255, 0.06) !important;
}
.sidebar-nav > a.hub-sidebar-portal .hub-sidebar-portal__meta,
aside.sidebar a.hub-sidebar-portal .hub-sidebar-portal__meta {
  opacity: 0.55;
  font-size: 10px !important;
}
.sidebar-nav > a.hub-sidebar-portal--switch,
aside.sidebar a.hub-sidebar-portal--switch {
  border: 1px dashed color-mix(in srgb, var(--accent, #f0a030) 38%, transparent) !important;
  background: color-mix(in srgb, var(--accent, #f0a030) 8%, transparent) !important;
}

.sidebar-footer {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 4px !important;
  padding: 8px 8px 10px !important;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.18));
}

.sidebar-footer a.side-action,
.sidebar-footer a.hub-owner-console,
.sidebar-footer a.hub-commander-link,
.sidebar-footer a:not(.side-action):not(.hub-owner-console) {
  min-height: 32px !important;
  padding: 5px 9px !important;
  font-size: 11px !important;
  border-radius: 9px !important;
  justify-content: flex-start !important;
}

.sidebar-footer form button,
.sidebar-footer .btn-close-month {
  min-height: 32px !important;
  padding: 5px 9px !important;
  font-size: 11px !important;
  border-radius: 9px !important;
}

.sidebar-footer .side-action--danger {
  color: #fecaca !important;
  border-color: rgba(248, 113, 113, 0.28) !important;
  background: rgba(239, 68, 68, 0.08) !important;
}
.sidebar-footer .side-action--danger:hover {
  background: rgba(239, 68, 68, 0.16) !important;
}

.sidebar-footer .side-action--switch-tenant {
  border-style: dashed !important;
  border-color: color-mix(in srgb, var(--accent, #f0a030) 42%, transparent) !important;
  background: color-mix(in srgb, var(--accent, #f0a030) 8%, transparent) !important;
}

/* Overlay — fade instead of hard show/hide */
.sidebar-overlay {
  display: block;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--k697-shell-dur) var(--k697-shell-ease),
    visibility 0s linear var(--k697-shell-dur);
  background: rgba(6, 10, 16, 0.52);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 199;
}
body.sidebar-open .sidebar-overlay {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity var(--k697-shell-dur) var(--k697-shell-ease), visibility 0s;
}

/* ═══════════════════════════════════════════════════════════════════
   MOBILE ≤900 — drawer + compact topbar + bottom-nav coexistence
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .topbar {
    flex-wrap: nowrap !important;
    align-items: center;
    gap: 4px !important;
    height: auto;
    padding-top: calc(6px + constant(safe-area-inset-top)) !important;
    padding-top: calc(6px + env(safe-area-inset-top, 0px)) !important;
    padding-inline: 8px !important;
    padding-bottom: 6px !important;
    min-height: calc(var(--k697-shell-top-h) + constant(safe-area-inset-top));
    min-height: calc(var(--k697-shell-top-h) + env(safe-area-inset-top, 0px));
    background: var(--bg-card, #fffcf7) !important;
  }

  .topbar-menu-btn {
    display: flex !important;
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border-radius: 12px;
  }

  .topbar .hub-nav-top {
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
    gap: 2px;
  }

  /* Mobile: system name only (brand chevron = portal) */
  .topbar .hub-crumb {
    display: flex !important;
    flex: 1 1 auto;
    min-width: 0;
    font-size: 11.5px;
    gap: 2px;
  }
  .topbar .hub-crumb__link,
  .topbar .hub-crumb__sep {
    display: none !important;
  }
  .topbar .hub-crumb__here {
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar .hub-back {
    flex-shrink: 0;
    padding: 6px !important;
    min-height: 40px;
  }

  .topbar .hub-tenant-chip {
    display: none; /* sidebar + switch link cover tenant change on phone */
  }

  /* Theme/pin stay in overflow panel rows — hide icon-only chrome if misplaced */
  .topbar > .k697-pin-btn,
  .topbar > .k697-density-btn,
  .topbar > .k697-theme-btn,
  .topbar .hub-nav-top > .k697-pin-btn,
  .topbar .hub-nav-top > .k697-density-btn,
  .topbar .hub-nav-top > .k697-theme-btn {
    display: none !important;
  }

  .topbar-meta {
    display: flex;
    flex: 0 0 auto;
    gap: 6px;
    align-items: center;
    min-width: 0;
  }
  /* Inline date never on the bar — date lives inside «المزيد» */
  .topbar-meta > .topbar-date { display: none !important; }
  .k697-top-more__section--date .topbar-date {
    display: inline-flex !important;
  }

  .topbar-user-chip {
    flex: 0 0 auto;
    padding: 3px 6px 3px 3px;
    gap: 4px;
    min-width: 0;
    max-width: none;
  }
  .topbar-user-chip .avatar {
    width: 28px;
    height: 28px;
    font-size: 11px;
  }
  .topbar-user-chip::after {
    content: "‹";
    font-size: 13px;
    font-weight: 900;
    opacity: 0.5;
    line-height: 1;
  }

  @media (max-width: 540px) {
    .topbar-user-chip > span:not(.avatar) { display: none; }
  }

  .k697-top-more {
    flex-shrink: 0;
  }
  .k697-top-more__btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
  }
  .k697-top-more__panel {
    position: fixed;
    top: calc(56px + env(safe-area-inset-top, 0px));
    inset-inline: 10px;
    width: auto;
    max-height: min(70vh, calc(100dvh - 120px));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  /* Keep decluttered tools reachable inside «المزيد» on phone */
  .k697-top-more__section--tools .k697-theme-btn,
  .k697-top-more__section--tools .k697-density-btn,
  .k697-top-more__section--tools .k697-pin-btn,
  .k697-top-more__tenant {
    display: inline-flex !important;
  }

  .topbar-search-btn {
    display: flex !important;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 12px;
    margin-inline-start: 0 !important;
    margin-inline-end: 2px;
  }

  .topbar-search {
    display: none;
    flex: 1 1 100%;
    max-width: none;
    min-width: 0;
    order: 20;
    margin: 0;
  }
  body.search-open .topbar {
    flex-wrap: wrap !important;
    height: auto;
  }
  body.search-open .topbar-search {
    display: block;
    padding-bottom: 2px;
  }

  /* Drawer: fixed off-canvas — no layout jump */
  .sidebar {
    position: fixed !important;
    inset-block: 0;
    inset-inline-end: 0;
    width: min(var(--k697-shell-side-w), 88vw) !important;
    flex: none !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    transform: translate3d(105%, 0, 0);
    will-change: transform;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: none;
    pointer-events: none;
  }
  html[dir="ltr"] .sidebar {
    inset-inline-end: auto;
    inset-inline-start: 0;
    transform: translate3d(-105%, 0, 0);
  }
  body.sidebar-open .sidebar {
    transform: translate3d(0, 0, 0);
    pointer-events: auto;
    box-shadow: -18px 0 48px -12px rgba(0, 0, 0, 0.45);
  }
  html[dir="ltr"] body.sidebar-open .sidebar {
    box-shadow: 18px 0 48px -12px rgba(0, 0, 0, 0.45);
  }

  body.sidebar-open {
    overflow: hidden;
    touch-action: none;
  }

  .sidebar-header {
    padding: 12px 10px 8px;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
  }
  .sidebar-brand-icon { width: 34px; height: 34px; font-size: 16px; }
  .sidebar-header h1 { font-size: 13.5px; }
  .sidebar-header .user-sub { font-size: 11px; }

  .sidebar-nav .nav-link {
    min-height: 40px;
    padding: 8px 10px;
    margin-inline: 6px;
  }

  .sidebar-footer {
    padding: 6px 6px calc(8px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* Bottom nav coexists — toast/dock already offset in polish */
  .phone-nav {
    z-index: 180;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .sidebar,
  .sidebar-overlay,
  .sidebar-nav .nav-link {
    transition: none !important;
  }
}

/* Print: hide shell (reinforces polish print rules) */
@media print {
  .sidebar,
  .topbar,
  .sidebar-overlay,
  .phone-nav,
  .k697-top-more {
    display: none !important;
  }
}
