.nav-item:focus-visible,
.nav-group-header:focus-visible,
#nav-more:focus-visible {
  outline: 3px solid rgba(var(--brand-green-rgb), .5);
  outline-offset: 2px;
  border-radius: 12px;
}

.app-command-sheet-modal {
  width: min(100%, 620px);
  max-height: min(82dvh, 720px);
  margin-inline: auto;
  border-radius: 22px !important;
}

.app-command-sheet {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
}

.app-command-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.app-command-heading h2 {
  margin: 0;
  color: var(--text);
  font-size: 19px;
  font-weight: 800;
}

.app-command-heading p,
.app-command-hint {
  margin: 4px 0 0;
  color: var(--text-3);
  font-size: 12px;
}

.app-command-sheet kbd {
  padding: 3px 7px;
  color: var(--text-3);
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 7px;
  font: inherit;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}

.app-command-search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 13px;
}

.app-command-search:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(var(--brand-green-rgb), .13);
}

.app-command-search input {
  width: 100%;
  min-width: 0;
  height: 48px;
  padding: 0;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: 0;
  font: inherit;
  font-size: 14px;
}

.app-command-search input:focus-visible {
  outline: 0;
}

#app-command-results {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: min(48dvh, 420px);
  overflow-y: auto;
}

.app-command-option {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 11px;
  text-align: left;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}

.app-command-option > span:first-child {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--brand);
  background: var(--bg-3);
  border-radius: 9px;
}

.app-command-option > span:nth-child(2) {
  flex: 1;
}

.app-command-option kbd {
  font-size: 10px;
  font-weight: 500;
}

.app-command-option:hover,
.app-command-option.is-active,
.app-command-option:focus-visible {
  background: var(--bg-2);
  border-color: var(--border);
  outline: none;
}

.app-command-empty {
  padding: 20px 10px;
  color: var(--text-3);
  text-align: center;
  font-size: 13px;
}

.app-command-hint {
  text-align: center;
}

.toast-with-action {
  gap: 10px;
}

.toast-undo {
  min-height: 36px;
  flex: 0 0 auto;
  padding: 0 11px;
  color: inherit;
  background: rgba(255, 255, 255, .16);
  border: 1px solid currentColor;
  border-radius: 9px;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.toast-undo:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

.pwa-update-notice {
  position: fixed;
  left: 50%;
  bottom: calc(82px + env(safe-area-inset-bottom, 0px));
  z-index: 10020;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: min(560px, calc(100vw - 24px));
  padding: 12px 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 12px 34px rgba(15, 23, 42, .18);
  transform: translateX(-50%);
}

.pwa-update-notice span {
  font-size: 12px;
  line-height: 1.4;
}

.pwa-update-notice button {
  min-height: 44px;
  flex: 0 0 auto;
  padding: 0 14px;
  color: #fff;
  background: var(--brand);
  border: 0;
  border-radius: 11px;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.pwa-update-notice button:focus-visible {
  outline: 3px solid rgba(var(--brand-green-rgb), .5);
  outline-offset: 2px;
}

.hr-card:focus-visible,
.meeting-card:focus-visible,
.wa-case-card:focus-visible,
.pipeline-card:focus-visible {
  outline: 3px solid rgba(var(--brand-green-rgb), .45);
  outline-offset: 3px;
}

.wa-case-card {
  min-height: 44px;
}

.hr-invite-sheet {
  max-height: calc(100dvh - env(safe-area-inset-top, 0px));
}

.dp-shell {
  min-height: 100svh;
  overflow-x: clip;
}

.dp-shell :is(button, a, input, textarea, select):focus-visible,
.portal-wrap :is(button, a, input, textarea, select):focus-visible {
  outline: 3px solid rgba(var(--brand-green-rgb), .55);
  outline-offset: 2px;
}

@media (max-width: 600px) {
  .pwa-update-notice {
    bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  }

  .app-command-sheet-modal {
    width: 100%;
    max-height: calc(100dvh - env(safe-area-inset-top, 0px));
    border-radius: 22px 22px 0 0 !important;
  }

  .app-command-sheet {
    padding: 16px 14px max(16px, env(safe-area-inset-bottom, 0px));
  }

  .sheet:has(#hr-new-name) .sheet-body > div {
    padding: 20px 16px max(24px, env(safe-area-inset-bottom, 0px)) !important;
  }

  .sheet:has(#hr-new-name) [style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 12px !important;
  }

  .sheet:has(#hr-new-name) input,
  .sheet:has(#hr-new-name) select {
    min-height: 48px;
    font-size: 16px !important;
  }

  .dp-hero {
    padding: max(24px, env(safe-area-inset-top, 0px)) 16px 22px !important;
    border-radius: 0 0 22px 22px !important;
  }

  .dp-hero h1 {
    font-size: clamp(21px, 6vw, 26px) !important;
    overflow-wrap: anywhere;
  }

  .dp-shell #dp-tabs {
    scroll-margin-top: 12px;
  }

  .portal-wrap {
    width: 100%;
    min-height: 100svh;
    overflow-x: clip;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-command-option,
  .toast-undo {
    transition-duration: .01ms !important;
  }
}

/* ══════════════════════════════════════════════════════════════
   NAVIGATION SIDEBAR — UI & UX NEXT-GEN (Designed by Improved)
   ══════════════════════════════════════════════════════════════ */

@media (min-width: 900px) {
  #app-sidebar,
  #bottom-nav,
  .bottom-nav,
  .sidebar {
    background: linear-gradient(180deg, #131316 0%, #0D0D0F 100%) !important;
    border-right: 1px solid rgba(255, 255, 255, 0.07) !important;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.35) !important;
  }

  /* Brand Header */
  #sidebar-brand {
    padding: 16px 16px 14px !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
    margin-bottom: 8px !important;
  }
  .sidebar-logo img {
    filter: drop-shadow(0 2px 8px rgba(0, 132, 95, 0.35));
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  }
  #sidebar-brand:hover .sidebar-logo img {
    transform: scale(1.08) rotate(-4deg);
  }
  .sidebar-title {
    font-size: 14.5px !important;
    font-weight: 900 !important;
    letter-spacing: -0.02em !important;
    color: #FFFFFF !important;
  }
  .sidebar-sub {
    font-size: 10.5px !important;
    font-weight: 700 !important;
    color: var(--brand, #00845F) !important;
    letter-spacing: 0.04em !important;
  }

  /* Section Labels */
  .nav-section-label {
    padding: 14px 18px 4px !important;
    font-size: 10.5px !important;
    font-weight: 800 !important;
    letter-spacing: 0.08em !important;
    color: rgba(255, 255, 255, 0.55) !important;
    text-transform: uppercase !important;
  }

  /* Group Headers */
  .nav-group-header {
    margin: 2px 10px !important;
    padding: 9px 12px !important;
    border-radius: 12px !important;
    color: rgba(255, 255, 255, 0.82) !important;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
    cursor: pointer;
  }
  .nav-group-header:hover {
    background: rgba(255, 255, 255, 0.05) !important;
    color: #FFFFFF !important;
    transform: translateX(2px);
  }
  .nav-group-header .chevron {
    transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
  }
  .nav-group.open .nav-group-header .chevron {
    transform: rotate(90deg) !important;
    color: var(--brand, #00845F) !important;
  }

  /* Nav Items */
  .nav-item {
    margin: 3px 10px !important;
    padding: 9px 12px !important;
    border-radius: 12px !important;
    color: rgba(255, 255, 255, 0.82) !important;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
    position: relative !important;
    overflow: hidden !important;
  }
  .nav-item .nav-icon {
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
    color: inherit !important;
  }
  .nav-item:hover {
    background: rgba(255, 255, 255, 0.06) !important;
    color: #FFFFFF !important;
    transform: translateX(4px) !important;
  }
  .nav-item:hover .nav-icon {
    transform: scale(1.12);
    color: var(--brand, #00845F) !important;
  }

  /* Active Nav Item */
  .nav-item.active {
    background: linear-gradient(90deg, rgba(0, 132, 95, 0.18) 0%, rgba(0, 132, 95, 0.03) 100%) !important;
    color: var(--brand, #00845F) !important;
    font-weight: 800 !important;
    border: 1px solid rgba(0, 132, 95, 0.22) !important;
    border-left: none !important;
    box-shadow: 0 4px 14px rgba(0, 132, 95, 0.12) !important;
  }
  .nav-item.active::before {
    content: "" !important;
    position: absolute !important;
    left: 0 !important;
    top: 6px !important;
    bottom: 6px !important;
    width: 3.5px !important;
    border-radius: 0 4px 4px 0 !important;
    background: var(--brand, #00845F) !important;
    box-shadow: 0 0 10px var(--brand, #00845F) !important;
  }
  .nav-item.active .nav-icon {
    color: var(--brand, #00845F) !important;
  }

  /* Badges */
  .nav-badge {
    background: #EF4444 !important;
    color: #FFFFFF !important;
    font-weight: 900 !important;
    font-size: 10px !important;
    border-radius: 10px !important;
    padding: 1px 6px !important;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.45) !important;
  }
}

/* Global high-contrast sidebar contrast guarantee (desktop) */
@media (min-width: 900px) {
  #bottom-nav,
  .bottom-nav,
  #app-sidebar,
  .sidebar {
    background: #111114 !important;
    background: linear-gradient(180deg, #141418 0%, #0D0D10 100%) !important;
    border-right: 1px solid rgba(255, 255, 255, 0.08) !important;
  }
  #bottom-nav .nav-label,
  .bottom-nav .nav-label,
  #app-sidebar .nav-label {
    color: rgba(255, 255, 255, 0.82) !important;
  }
  #bottom-nav .nav-section-label,
  .bottom-nav .nav-section-label,
  #app-sidebar .nav-section-label {
    color: rgba(255, 255, 255, 0.52) !important;
  }
  #bottom-nav .nav-group-header,
  .bottom-nav .nav-group-header,
  #app-sidebar .nav-group-header {
    color: rgba(255, 255, 255, 0.82) !important;
  }
  #bottom-nav .nav-item:hover,
  .bottom-nav .nav-item:hover {
    color: #FFFFFF !important;
  }
  #bottom-nav .nav-item.active,
  .bottom-nav .nav-item.active {
    color: var(--brand) !important;
  }
}

.sidebar-collapse-btn { background: rgba(255, 255, 255, 0.08) !important; color: rgba(255, 255, 255, 0.7) !important; border: 1px solid rgba(255, 255, 255, 0.12) !important; }
.sidebar-collapse-btn:hover { background: rgba(255, 255, 255, 0.15) !important; color: #FFFFFF !important; }
